CSS Attribute Selector Part 2

Notes:

CSS Attribute Selector (Square Brackets) - Part 2:

1.
[attribute name]
{
declaration list;
}
It selects any html element, which contains an attribute name written in between the square brackets

Ex:
[align]
{
border:2px solid red;
}
It selects any html element, which contains an attribute with the name align

2.
selector[attribute name]
{
declaration list;
}
It selects any html element targeted by the selector, which contains an attribute name written in between the square brackets

Ex:
p[align]
{
border:2px solid red;
}
It selects any paragraph element, which contains an attribute with the name align

3.
selector[attribute name=”value”]
{
declaration list;
}
It selects any html element targeted by the selector, which contains an attribute name where the attribute value exactly matches with the value specified in attribute expression

Ex:
p[align=”center”]
{
border:2px solid red;
}
It selects any paragraph element, which contains an attribute align, where the align attribute value exactly matches with the value center.

Interview Questions: