Attribute selectors - CSS | CSS selector has
TheCSSattributeselectormatcheselementsbasedonthepresenceorvalueofagivenattribute.a[title]{color:purple;}a[href="https://example.org"]{color:green;}a[href*="example"]{font-size:2em;}a[href$=".org"]{font-style:italic;}a[class~="logo"]{padding:2px;}[attr]Representselementswithanattributenameofattr.[attr=value]Representselementswithanattributenameofattrwhosevalueisexactlyvalue.[attr~=value]Representselementswithanattributenameofattrwhosevalueisawhitespace-separatedlistofwords,oneofwhichisexactly...
The CSS attribute selector matches elements based on the presence or value of a given attribute.
a[title] { color: purple; } a[href="https://example.org"] { color: green; } a[href*="example"] { font-size: 2em; } a[href$=".org"] { font-style: italic; } a[class~="logo"] { padding: 2px; } [attr]Represents elements with an attribute name of attr.
[attr=value]Represents elements with an attribute name of attr whose value is exactly value.
[attr~=value]Represents elements with an attribute name of attr whose value is a whitespace-separated list of words, one of which is exactly value.
[attr|=value]Represents elements with an attribute name of attr whose value can be exactly value or can begin with value immediately followed by a hyphen, - (U+002D). It is often used for language subcode matches.
[attr=value]Represents elements with an attribute name of attr whose value is prefi...