Easy Tutorial
❮ Pr Margin Right Css3 Pr Transition Duration ❯

CSS [attribute|=value] Selector

Complete CSS Selector Reference

Example

Select all elements where the lang attribute is exactly en or starts with en-, and apply the following styles:

[lang|=en]
{ 
    background-color:yellow;
}

Definition and Usage

The [*attribute*|=*value*] selector is used to select elements with the specified attribute starting with the specified value.

Note: The value must be a whole word, either standalone like lang="en" or followed by a hyphen - such as lang="en-us".


Browser Support

All major browsers support the [*attribute*|=*value*] selector.

Note: The [*attribute*|=*value*] selector works in IE8, but it must be declared with <!DOCTYPE>.


Related Articles

CSS Tutorial: CSS Attribute Selectors


More Examples

Example

Select all elements with a class attribute that starts with top, and set their background color to yellow:

[class|=top]
{ 
    background-color:yellow;
}

❮ Pr Margin Right Css3 Pr Transition Duration ❯