CSS Attr Selectors
Style HTML elements with specific attributes or attribute values.
CSS Attribute Selectors
Style HTML elements with specific attributes or attribute values.
Example 1: [attribute] Selector
The [attribute] selector is used to select elements with a specified attribute.
Example 2: [attribute="value"] Selector
The [attribute="value"] selector is used to select elements with a specified attribute and value.
Example 3: [attribute~="value"] Selector
The [attribute~="value"] selector is used to select elements with an attribute value containing a specified word.
The image with the title attribute containing the word "flower" gets a yellow border:
Example 4: [attribute|="value"] Selector
The [attribute|="value"] selector is used to select elements with the specified attribute starting with the specified value.
Welcome
Hello world!
Are you learning CSS?
Example 5: [attribute^="value"] Selector
The [attribute^="value"] selector is used to select elements whose attribute value begins with a specified value.
Welcome
Hello world!
Are you learning CSS?