We can set style using attribute or its value.
Set Style using attribute : –
Syntax: –
Selector [attribute] { CSS ;}
Ex: –
div [id] { color: red; }
Set style using attribute and its value: –
Syntax: –
Selector [attribute = “value”] { CSS }
Ex: –
div[id=“data”] { color: red; }
Set Style using an attribute value containing a specified word.
Syntax: –
[attribute ~= “value”] { CSS }
Ex:-
[class ~= “game”] { color: red; }
Set Style using with the specified attribute starting with the specified value.
Syntax: –
[attribute |= “value”] { CSS }
Ex:-
[class |= “game”] {color: red;}
The value must be a whole word.
Ex: –
“game” or “game-super”
Set Style whose attribute value begins with a specified value.
Syntax: –
[attribute ^= “value”] { CSS }
Ex:-
[class ^= “game”] {color: red;}
It is not necessary that the value should be a whole word.
Set Style whose attribute value ends with a specified value.
Syntax: –
[attribute $= “value”] { CSS }
Ex:-
[class $= “game”] {color: red;}
It is not necessary that the value should be a whole word.