Detailed CSS Property Selector

Source: Internet
Author: User
Sets the style for the HTML element with the specified property. You can set the style for the HTML element that owns the specified property, not just the class and ID properties. This article mainly introduces the CSS property selector related knowledge, interested friends to see together, hope to help everyone.

Note: Only in the rules! DOCTYPE, IE7 and IE8 only support property selectors. In IE6 and lower versions, attribute selection is not supported.

Property Selector

The following example sets the style for all elements with the title property:


[Title] {color:red;}

Properties and Value selectors

The following example sets the style for all elements of title= "W3school":


[Title=w3school] {border:5px solid blue;}

Properties and value selectors-multiple values

The following example sets the style for all elements that contain the title property of the specified value. Applies to property values separated by spaces:


[Title~=hello] {color:red;}

The following example sets the style for all elements with the lang attribute that contains the specified value. Applies to attribute values separated by hyphens:


[Lang|=en] {color:red;}

Set the style of a form

The property selector is especially useful when styling a form that does not have a class or ID:


Input[type= "text"]{  width:150px;  Display:block;  margin-bottom:10px;  Background-color:yellow;  Font-family:verdana, Arial;} Input[type= "button"]{  width:120px;  margin-left:35px;  Display:block;  Font-family:verdana, Arial;}

CSS Selector Reference Manual

selector

description

[attribute]

[attribute=value]

[attribute~=value]

[attribute|=value]

[attribute^=value]

matches the attribute value to specify each element at the beginning of the value.

[attribute$=value]

matches the attribute value to specify each element at the end of the value.

[attribute*=value]

matches each element of the attribute value that contains the specified value.

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.