Three selector Types of CSS are described in detail.

Source: Internet
Author: User
HTML selector
HTML selector is the tags of HTML, such as P, DIV, and TD. if you define them with CSS, the nature of the Tag will be displayed according to your definition on the whole page. the syntax of HTML selector is as follows:
Tag {property: value}. For example, the color of H1 is the red H1 {color: red}. Here we also want to tell you a feature of CSS, it can define several selectors in a rule. for example, if H1, H2, TD {color: red} is defined, the colors of H1, H2, and TD are red.
Class selector
There are two types of Class selector: one is related to a class selector, which is related to an HTML tag. its syntax is tag. classname {property: value}. For example, if we want to name some H1.redone {color: red} instead of all H1 colors, in the following statement, the first H1 is red, the second one is not.
Red Question
Common questions
The second type is independent class selector. it can be applied by any HTML tag. its syntax is as follows. classname {property: value} suppose we have the following definition. blueone {color: blue} then we can apply it to different tags. for example
Blue question
Blue paragraph
Obviously, class selector gives us more freedom.
ID selector
The ID selector is actually the same as the function of the independent class selector, but the difference is that their syntax and usage are different, and for the & #106 avas handler to manipulate HTML
The element is helpful. its syntax is as follows # IDname {property: value}. If we have the following definition # yelowone {color: yellow}, we can use this to define any tag with the same ID name, for example, text here, you may think that since the ID selector and the independent class selector have the same functions, why do they both exist. if you know how to position them with CSS-P, you will understand the difference between them. HTML elements with IDs can be manipulated by CSS-P and & #106 avas metadata. So far, you have probably learned how to write CSS Definitions. The following five sections will show you how to use CSS to manipulate or modify them.


Related Article

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.