CSS basic tutorial basic selector

CSS Selector

1. Basic Selector



(1) "*" selector: wildcard

  • Description: will match All HTML tags, all tags will change.

  • Grammar: *{ color:red; }

Note: Use "*" as little as possible , because IE6 does not support it.

    php.cn  

习近平心中的互联网

互联网是20世纪最伟大的发明,它正在将人类“一网打尽”,人们在不知不觉中已经融入了互联网生态,互联网让世界变成了“鸡犬之声相闻”的地球村。



(2) Tag selector

Description: Will match the specified HTML tag.

Syntax: h1{ color:red; }

Note: The CSS tag selector has the same name as the HTML tag, but angle brackets cannot be added.

    php.cn  

习近平心中的互联网

互联网是20世纪最伟大的发明,它正在将人类“一网打尽”,人们在不知不觉中已经融入了互联网生态,互联网让世界变成了“鸡犬之声相闻”的地球村。



(3) class selector (class selector) - class selector is the most frequently used

Description: Add styles to a type of HTML tags. The "one class" referred to here is: each HTML tag has a class attribute, and the value of class is the same. The class attribute is a public attribute that every HTML tag has.

The name of the class selector must start with "." and be limited to the value of the class attribute of the HTML tag. For example: .box{ color:red; }

Note: The value of the class attribute of the HTML tag cannot start with a number.

    php.cn  

习近平心中的互联网

互联网是20世纪最伟大的发明,它正在将人类“一网打尽”,人们在不知不觉中已经融入了互联网生态,互联网让世界变成了“鸡犬之声相闻”的地球村。



(4) id selector

Description: Add style to the element with the specified id.

Note:

  • The value of the id attribute of the HTML tag in the web page must be unique.

  • Every HTML tag has a public attribute of id.

  • The id attribute is generally used for JS, not for you to add styles. The class attribute can only be used for CSS, not JS.

  • The name of the id selector must start with "#", followed by the value of the id attribute of the HTML tag.

    php.cn  

习近平心中的互联网

互联网是20世纪最伟大的发明,它正在将人类“一网打尽”,人们在不知不觉中已经融入了互联网生态,互联网让世界变成了“鸡犬之声相闻”的地球村。


Continuing Learning
||
php.cn

习近平心中的互联网

互联网是20世纪最伟大的发明,它正在将人类“一网打尽”,人们在不知不觉中已经融入了互联网生态,互联网让世界变成了“鸡犬之声相闻”的地球村。

submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!