Prev Page Next Page
Top

CSS [attribute] Selector

➢The [attribute] selector is used to select elements with a specified attribute.

EXAMPLE:

a[target] {
     background-color: lightgreen;

}

Run


CSS [attribute="value"] Selector

➢The [attribute="value"] selector is used to select elements with a specified attribute and value.

EXAMPLE:

a[target="_blank"] {
     background-color: lightgreen;

}

Run


CSS [attribute~="value"] Selector

➢The [attribute~="value"] selector is used to select elements with an attribute value containing a specified word.

EXAMPLE:

[title~="flower"] {
     border: 5px solid lightgreen;

}

Run


CSS [attribute|="value"] Selector

➢The [attribute|="value"] selector is used to select elements with the specified attribute, whose value can be exactly the specified value, or the specified value followed by a hyphen (-).

EXAMPLE:

[class|="top"] {
     background: lightgreen;

}

Run


CSS [attribute^="value"] Selector

➢The [attribute^="value"] selector is used to select elements with the specified attribute, whose value starts with the specified value.

EXAMPLE:

[class^="top"] {
     background: lightgreen;

}

Run


CSS [attribute$="value"] Selector

➢The [attribute$="value"] selector is used to select elements whose attribute value ends with a specified value.

EXAMPLE:

[class$="test"] {
     background: lightgreen;

}

Run


CSS [attribute*="value"] Selector

➢The [attribute*="value"] selector is used to select elements whose attribute value contains a specified value.

EXAMPLE:

[class*="te"] {
     background: lightgreen;

}

Run


Prev Page Next Page