Home  >  Article  >  Web Front-end  >  What is css class

What is css class

藏色散人
藏色散人Original
2020-12-24 09:37:244110browse

css class is the class selector of CSS, that is, the class selector; 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 element; this selector can be used alone or in combination with other elements.

What is css class

The operating environment of this article: windows10 system, css 3, thinkpad t480 computer.

Recommended: "css Video Tutorial"

css class refers to the CSS class (class) selector, allowing it to be selected in a way that is independent of document elements. Specify the style.

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 ".":

Example: All HTML with the center class The elements are all centered

<h1 class="center">标题居中</h1>
<p class="center">段落居中。</p>
.center{
text-align:center;
}

Rendering:

What is css class

You can also specify specific HTML elements using class.

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:

What is css class

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 css class. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn