Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

CSS [attribute~=value] selector

CSS [attribute~=value] selector

Complete CSS SelectorComplete CSS Selector Reference Manual

Example

Selects all elements whose title attribute contains the word "flower"

[

title

~=

flower

]

{

background-color:

yellow

;

}

Try it »


Definition and Usage

[attribute~=valueThe ] selector is used to select elements whose attribute value contains a specified word.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support [attribute~=value] selector.

Note:[attribute~=value] must have a DOCTYPE declared to work in IE8 .


Related Articles

CSS Tutorial: CSS attribute selectors


Complete CSS SelectorComplete CSS Selector Reference Manual