In CSS3, the class selector refers to the class selector, which allows you to specify styles in a way that is independent of document elements. It is used to describe the style of a group of elements and can be used in multiple elements. use. The class selector is represented by the class attribute in HTML and a dot "." in CSS.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
In CSS3, the class selector refers to the class selector, which is one of the most basic selectors.
The class selector allows you to specify styles in a way that is independent of document elements. It is used to describe the style of a group of elements and can be used in multiple elements.
The class selector is represented by the class attribute in HTML. In CSS, the class selector is displayed with a dot ".":
html code
<h1 class="center">标题居中</h1> <p class="center">段落居中。</p>
CSS Code
.center{text-align:center;}
Note: Numbers cannot be used as the first character of the class name! It won't work in Mozilla or Firefox.
The class selector can be used alone or in combination with other selectors.
.fancy td { color: #f60; background: #666; }
In the above example, the table cells inside the larger element with the class name fancy will display orange text on a gray background. (The larger element named fancy may be a table or a div)
td.fancy { color: #f60; background: #666; }
In the above example, the table cell with class name fancy will be orange with a gray background.
(Learning video sharing: css video tutorial)
The above is the detailed content of What is the class selector in css3. For more information, please follow other related articles on the PHP Chinese website!