What are the CSS selectors

Source: Internet
Author: User

Tag: Match is a space HTM attribute selector usage use col

CSS selectors are still relatively rich, the main CSS selector is as follows:

    1. Tag Selector (for example: Body,div,p,ul,li)

    2. . class selector (e.g.: class= "Head", class= "Head_logo")

    3. ID Selector (for example: id= "name", id= "Name_txt")

    4. Global selector (e.g., *)

    5. . Combo selector (e.g.:. Head Head_logo, note two selector separated by SPACEBAR)

    6. . Inherit selectors (e.g. Div p, note two selector separated by SPACEBAR)

    7. Pseudo-class selectors such as: Link style, Pseudo-class of element A, 4 different states: link, visited, active, hover. )

    8. String Matching Property selector (^ $ * three, respectively, corresponding to start, end, inclusive)

The above selectors are most commonly used in the daily development of tag selectors, class selectors, and ID selectors, following the basic usage of these three types of selectors:

1. Tag name Selector
There are many tags in an XHTML document, such as P tags, h1 tags, and so on. To make all P tags in a document use the same CSS style, you should use a tag Selector.

div {color:red;border:1px blue solid;} p {color: #000;}

  

2. Class Selector
You can use the tag selector to specify the same CSS style for the same tag in the entire XHTML document. In practice, however, the same tag in an XHTML document is reused. To assign a different CSS style to the same label, you should use the class selector.

<div class= "Test" > Test code </div>. Test {color:red;border:1px blue solid;}

  

3, ID selector, ID selector is unique, can only get a unique element.

<div id= "Test" > Test code </div> #test {color:red;border:1px blue solid;}

  

What are the CSS selectors

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.