A summary of class usage and specifications

Source: Internet
Author: User
In CSS, we are common to the selector class, then for class usage and specification, we will make a summary:

About the 1.CSS Id and class selector

ID and Class Selector

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 an HTML element that is labeled with a specific ID.

The HTML element sets the ID selector with the id attribute, and the ID selector in the CSS is defined as "#".

The difference between 2.a.class and A. Class, note the space-CSS debugging tips

This problem occurs when using picture sprites to position images, and sometimes a space can cause a lot of problems, this article introduces the difference between A.class and Class A.

3. The principle of using both ID and class in CSS

First, describe the difference between ID and class:

The ID is a label that distinguishes between different structures and content; The ID is the structure/content that is first found, then the style is defined, and the class is a style that can be set on any structure or content; class is defined as a style and then set to multiple structures/content.

4. Introduction to common naming conventions for page layouts class

This article is mainly for everyone in-depth analysis of the page layout class common naming norms related data, with a certain reference value, interested in small partners can refer to

What is the difference between 5.id and class, using class or ID

In the previous two articles we talked about the knowledge and how to use class and ID, but how do we choose the class or ID in the actual project?

First look at the difference between the two!

ID is unique and class is universal, so a page can only be used once for the same ID, and class can be used without restrictions.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.