Home > Article > Web Front-end > Summary of class usage and specifications
In CSS, we often see the selector class, so let’s make a summary of the usage and specifications of class:
1.Introduction to CSS Id and Class selector
id and class selectors
If you want to set CSS styles in HTML elements, you need to set the "id" and "class" selectors in the element.
id selector
The id selector can specify a specific style for HTML elements marked with a specific id.
The HTML element uses the id attribute to set the id selector, and the id selector in CSS is defined with "#".
2.The difference between a.class and a.class, pay attention to the spaces - CSS debugging skills
Use picture sprite technology This problem occurs when positioning pictures. Sometimes a space can cause many problems. This article introduces the difference between a.class and a.class with examples.
3.Detailed explanation of the principle of using both id and class in css
First, introduce the difference between id and class:
id is a label used to distinguish different structures and contents; id is to find the structure/content first, and then define a style for it; class is a style that can be applied to any structure and content; class is defined first Use one style and apply it to multiple structures/contents.
4.Introduction to common naming conventions for page layout classes
This article mainly provides an in-depth analysis of page layout classes for everyone. Information related to common naming conventions has certain reference value. Interested friends can refer to
5.The difference between id and class, use class Or ID
In the previous two articles, we talked about the relevant knowledge and how to use class and id respectively, but in actual projects, how should we choose, class or id?
Let’s review the differences between the two first!
ID is unique and class is universal, so the same id can only be used once on a page, while class can be used without restriction.
The above is the detailed content of Summary of class usage and specifications. For more information, please follow other related articles on the PHP Chinese website!