In the css attribute selector, [attribute ~ = Value] and [attribute * = value]

Source: Internet
Author: User

In the css attribute selector, [attribute ~ = Value] and [attribute * = value]

[Attribute] is used to select an element with a specified attribute. [Attribute = value] is used to select elements with specified attributes and values. [Attribute ~ = Value] is used to select the elements in the attribute value that contain the specified vocabulary. [Attribute | = value] is used to select an element with an attribute value starting with a specified value. The value must be the entire word. [Attribute ^ = value] matches each element whose attribute value starts with a specified value. [Attribute $ = value] matches each element whose attribute value ends with a specified value. [Attribute * = value] matches each element of a specified value in a property value.

 

 

The following example sets a style for all elements that contain the title attribute of the specified value. Applicable to attribute values separated by spaces: [title ~ = Hello] {color: red;} The following example sets a style for all elements with the lang attribute containing the specified value. Applies to attribute values separated by hyphens: [lang | = en] {color: red ;}

 

~ = The value must be an independent word, for example, [title ~ In = test], test a can be selected. testa cannot be selected.
* = The value can be a substring Of the value. For example, test-a, test a, and testa can be selected.
| = And ~ = Features are the same, ^ = and * = features are the same. Therefore, it is better to use ^ = and * = at ordinary times.

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.