CSS [attribute=value] Selector (original) (raw)

Last Updated : 29 Aug, 2024

The [attribute=value] selector in CSS is used to select those elements whose attribute value is equal to "value".

**Syntax:

element [attribute = "value"] {
// CSS Property
}

**Note: <!DOCTYPE> must be declared for IE8 and earlier versions.

**Example 1: In this example, The selector h1[id="geeks"] targets the h1 element with id="geeks" and applies a green background color and white text color and The selector li[class="gfg"] targets li elements with class="gfg" and sets the text color to green.

html `