CSS Attribute Selectors
- turned_in_notProperty
- [attribute]
- [attribute="value"]
- [attribute|="value"]
- [attribute~="value"]
- [attribute^="value"]
- [attribute$="value"]
- [attribute*="value"]
[attribute]
It selects all elements having specified attribute
/*Syntax*/
selector[attribute] {
/*css properties*/
}
<p id="ab">welcome</p>
<div id="aa"> Hello..!</div>
Try below options to see comment
[attribute="value"]
It selects all elements having specified attribute with specified value
/*Syntax*/
selector[attribute="value"] {
/*css properties*/
}
<p id="abc"> welcome</p>
<p id="bcd"> hello</p>
[attribute|="value"]
It selects all elements having specified attribute with specified value equal to or followed by a hyphen(-)
/*Syntax*/
selector[attribute|="value"]{
/*css properties*/
}
<p className="ab">Hello friends!</p>
<p className="ab-cd">Good Luck !</p>
[attribute~="value"]
It selects all elements having specified attribute containing a specified value
/*Syntax*/
selector[attribute~="value"]{
/*css properties*/
}
<p className="aa ab">Hello friends!</p>
<p className="cd de">Good Luck !</p>
[attribute^="value"]
It selects all elements having specified attribute begins with specified value
/*Syntax*/
selector[attribute^="value"]{
/*css properties*/
}
<p className="abc">Hello friends!</p>
<p className="xyz">Good Luck !</p>
[attribute$="value"]
It selects all elements having specified attribute ends with specified value
/*Syntax*/
selector[attribute$="value"]{
/*css properties*/
}
<p className="apple">Apple !</p>
<p className="mango">Mango !</p>
[attribute*="value"]
It selects all elements having specified attribute which contains substring as specified value
/*Syntax*/
selector[attribute*="value"]{
/*css properties*/
}
<p className="apple">Apple !</p>
<p className="mango">Mango !</p>