CSS [attribute|=value]Selectors
Complete CSS Selector Reference Manual
Example
Select lang attribute equal toen, or withen-Select all elements that begin with the specified value, and set their style:
[lang|=en]
{
background-color:yellow;
}
Try it Yourself »
Definition and Usage
[attribute|=value] selector is used to select elements whose attribute value starts with a specified value.
Note:The value is a whole word, whether standalone like lang="en", or with a hyphen-For examplelang=en-usAnything is fine.
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers supportattribute|=value] selector.
Note: [attribute|=valueTo run in IE8, a declaration is required.<!DOCTYPE>
Related Articles
CSS Tutorial:CSS Attribute Selectors
More Examples
Example
Select all elements with a class attribute that starts with top, and set them to yellow:
[class|=top]
{
background-color:yellow;
}
Try it Yourself »
Complete CSS Selector Reference Manualother extensions