CSS attribute Selector

Source: Internet
Author: User

In addition to the common "type selector (E), wildcard selector (*), include selector (E1 E2), and Id selector (# ID), selector grouping (E1, E2, E3), class selector (E. class), pseudo class, and pseudo object selector (E: P), and "attribute selector (E [ATTR])" and "adjacent selector (E1 + e2) ", tried the attribute selector, it feels very good, if used in the page, it will make CSS definition more powerful, but unfortunately now IE does not support this selector.

Attribute delimiters can be divided into the following types:

Attribute selectors
E [ATTR] attribute selector.
Select e with the ATTR attribute.

Attribute selectors
E [ATTR = value] attribute selector.
Select e with the ATTR attribute and the attribute value is equal to the value.

Attribute selectors
E [ATTR ~ = Value] attribute selector.
Select a word list with the ATTR attribute and the attribute value is separated by spaces. One of the words is equal to the value of E.

Attribute selectors
E [ATTR | = value] attribute selector.
Select a word list that has the ATTR attribute and the attribute value is separated by a hyphen. e starts with value.

The following is an example:

-------------------- HTML code ----------------------
<Div class = "Demo"> E [ATTR = value] attribute selector </div>
<Div Title = "attribute selectors"> E [ATTR] attribute selector </div>
<H1 class = "dem Demo"> E [ATTR ~ = Value] attribute selector <H2 class = "demo-demo2"> E [ATTR | = value] attribute selector </H2>
------------------------------------------------------------

------------------ CSS code -----------------------
Body {Line-Height: 1.3em; color: #000000 ;}
. Demo-demo2 {background-color: # ffa500 ;}
Div [title] {color: # ffffff; Background-color: # 0000ff ;}
Div [class = demo] {color: # ff0000 ;}
H1 [class ~ = Demo] {color: # 0000ff ;}
H2 [class | = demo] {color: #008000 ;}
-----------------------------------------------------------

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.