These attribute selectors allows selecting matching strings in the value of an attribute.
# Occurs
These attribute selectors allows selecting matching strings in the value of an attribute.
# Syntax
Copy
[attribute] {
/* declarations */
}
# Example
Copy
[title] {
border-bottom: 1px solid black;
}
0
Try example in CodePen# Browser support
Platform
Chrome
Firefox
Safari
Edge
Internet Explorer
Opera
Desktop
Yes (1)
Yes (1)
Yes (1)
Yes (12)
Yes (7)
Yes (6)
Mobile
Yes (1)
Yes (1)
Yes (1)
Yes (12)
Yes (7)
Yes (2)
# Exactly
These attribute selectors allows selecting matching strings in the value of an attribute.
# Syntax
Copy
[attribute="value"] {
/* declarations */
}
# Example
Copy
[lang="en"] {
border-bottom: 1px solid black;
}
0
Try example in CodePen# Browser support
Platform
Chrome
Firefox
Safari
Edge
Internet Explorer
Opera
Desktop
Yes (1)
Yes (1)
Yes (1)
Yes (12)
Yes (7)
Yes (6)
# Whitespace
These attribute selectors allows selecting matching strings in the value of an attribute.
# Syntax
Copy
[attribute~="value"] {
/* declarations */
}
# Example
Copy
[class~="alert"] {
background-color: red;
}
0
Try example in CodePen# Browser support
Platform
Chrome
Firefox
Safari
Edge
Internet Explorer
Opera
Desktop
Yes (1)
Yes (1)
Yes (1)
Yes (12)
Yes (7)
Yes (6)
# Hyphen
These attribute selectors allows selecting matching strings in the value of an attribute.
# Syntax
Copy
[attribute|="value"] {
/* declarations */
}
# Example
Copy
[lang|="en"] {
border: 1px solid blue;
}
0
Try example in CodePen# Browser support
Platform
Chrome
Firefox
Safari
Edge
Internet Explorer
Opera
Desktop
Yes (1)
Yes (1)
Yes (1)
Yes (12)
Yes (7)
Yes (6)
Please wait a moment, the comments start loading now...