CSS selector types

Source: Internet
Author: User

  1. type selector : Selects all elements of a type. The type selector refers to the element name without a less than or greater than sign. such as: DIV,IMG, etc.
  2. class selector : Select all the elements of the specified class. The format of the class selector is followed by a period appended with the class name. For example:. myclass{}
  3. ID Selector : Selects all elements of the specified ID in the document. Each element has only one ID and must remain unique within the document.
  4. Property Selector :
    1. Property Existence Selector : lets you select the element that contains the specified attribute. The format of the attribute selection existence selector is the total parentheses plus the attribute name. For example: P[title] You can select all P elements that contain the title attribute. Some browsers do not recognize empty properties such as <p title= " "></p>
    2. Property Word selector : Allows you to select the element that contains the specified word in the specified attribute. For example, p[title~= "MyTitle" can select all P element words that contain the word MyTitle in the Title property, which must be separated by a space, and the characters are case-sensitive. <p title= "This is MyTitle" ></p>
    3. Property Value Selector : Can be used to select the specified attribute that contains the specified element. The property value selector. such as p[title= "#4 mytitle"] You can choose the Title property value is exactly the P element of the # MyTitle. Characters are case-sensitive, Must include a space, including a complete property value
  5. pseudo-Element selectors : First-letter,first-line is called a pseudo-element selector because they select only part of the element, not all of the elements. In other words, they create a pseudo-element. For example: P: first-line{}, select the first line below the P element.
  6. pseudo-Class selector : Applies only to hyperlinks. A:hover,a:link,a:visited,a:active,a:focus. (css2.1 defines two other pseudo-class selectors: Fist-child,lang (). CSS3 also defines pseudo-class selectors such as Nth-child (n-1), and can be used with pseudo-class selectors on labels other than hyperlinks)
  7. Subclass Selector: Use a wildcard selector, add a point, add a base class name, and add a point. Finally, the subclass name allows you to select all the elements that have the base class set. This is sleeping in tandem class. The concatenation class can have an infinite number of suggested base classes before, and after subclasses, the concatenation class does not have to be relevant. But dividing them by class and subclass can add logic to the code. such as:. class.subclass.etc{}

CSS selector types

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.