In css style, class refers to the CSS class selector, which allows styles to be specified in a way that is independent of document elements; class selectors allow styles to be specified in a way that is independent of document elements. A style used to describe a group of elements and can be used in multiple elements.
The operating environment of this article: Windows 7 system, CSS3 version, Dell G3 computer.
css class refers to the CSS class selector, which allows styles to be specified in a way that is independent of document elements. The following article will introduce you to the CSS class selector. I hope it will be helpful to you.
CSS class selector
The class selector allows you to specify styles in a way that is independent of document elements and is used to describe the style of a group of elements. , can be used in multiple elements.
This selector can be used alone or in combination with other elements.
To apply styles regardless of the specific design element, the most common way is to use a class selector.
The class selector is represented by the class attribute in HTML. In CSS, the class selector is displayed with a dot ".":
[Recommended: css video Tutorial】
Example: All HTML elements with the center class are centered
<h1 class="center">标题居中</h1> <p class="center">段落居中。</p> .center{ text-align:center; }
Rendering:
You also Specific HTML elements can be specified using classes.
Example: Use class="center" for all p elements to center the text of the element
<h1 class="center">这个标题不受影响</h1> <p class="center">这个段落居中对齐。</p> p.center { text-align:center; }
Rendering:
Note : In class selectors, numbers cannot be used as the first character of the class name! It won't work in Mozilla or Firefox.
The above is the detailed content of What is class in css style. For more information, please follow other related articles on the PHP Chinese website!