HTML and CSS Reference
In-Depth Information
This selector will match any elements whose
lang
attribute value begins with “en”,
such as “en-US”. Note that language codes such as these are case insensitive.
<p lang="en">English</p>
<p lang="en-US">American English</p>
Delimited value selector
The
[attribute~=value]
selector will apply to elements whose attribute value contains
the given word among a space-separated list of words.
input[value~="word"] {}
This rule will select both of the following elements. The word needs to be an exact
case-sensitive match; for example, the selector will not target “Word” or “words”.
<input type="text" value="word">
<input type="text" value="word word2">
Value substring selector
The
[attribute*=value]
selector matches elements whose attribute value contains the
specified substring.
p[title*="para"] {}
Paragraph elements with a
title
containing “para” will be matched by this rule.
<p title="my paragraph"></p>
Value start selector
The
[attribute^=value]
selector matches every element whose attribute value begins
with the specified string.
p[title^="first"] {}
Paragraphs with a
title
value starting with “first” will have this rule applied.
<p title="first paragraph"></p>