Categories of selectors
HTML tags
are widely used. Pay attention to the application of inheritance, composition and association (P119).
User-defined class selector
A class can be named by any name.
All elements in
can define "classes".The syntax is as follows:
selector.classname{property1:value1; property2:value2;…}
.classname{property1:value1; property2:value2;…}
1. What is the difference between the two definition forms?
2. How to use class selector style in tags?
ID selector
The application form is basically similar to the class selector. Use "#" instead of "." when defining.
Therefore, one of them is generally selected when applying. See example on page 120.
Virtual classes and virtual elements
There is no such attribute in HTML page elements, so it is called a virtual class. Only browser versions above IE5.0 support virtual class selection. symbol.
The syntax is as follows:
Page element name: element virtual attribute name {style sheet content}
a:link {color: #000000}
a :visited {color: #cccccc}
a:hover {color: #000000; font-style:italic}
a:active {color: #aaaaaa}
:link {color: #000000}
:visited {color: #cccccc}
:hover {color: #000000; font-style:italic}
:active {color: #aaaaaa}