CSS Selector Level 3 » Attribute

This are attribute selectors which provide selecting matching strings in the value of an attribute.
These CSS3 selectors already occurred less powerful as attribute selectors in CSS2.


# Prefix

This are attribute selectors which provide selecting matching strings in the value of an attribute.
These CSS3 selectors already occurred less powerful as attribute selectors in CSS2.

# Syntax

Copy
[attribute^=value] {
    /* declarations */
}

# Example

Copy
a[href^="https://"] {
    border-bottom: 1px solid red;
}

0

Try example in CodePen

# Browser support

Platform Chrome Firefox Safari Edge Internet Explorer Opera
Desktop Yes (1) Yes (3) Yes (1) Yes (12) Yes (8) Yes (9.5)

# Suffix

This are attribute selectors which provide selecting matching strings in the value of an attribute.
These CSS3 selectors already occurred less powerful as attribute selectors in CSS2.

# Syntax

Copy
[attribute$=value] {
    /* declarations */
}

# Example

Copy
a[href$=".pdf"] {
    border-bottom: 1px solid red;
}

0

Try example in CodePen

# Browser support

Platform Chrome Firefox Safari Edge Internet Explorer Opera
Desktop Yes (1) Yes (3) Yes (1) Yes (12) Yes (8) Yes (9.5)

# Contains

This are attribute selectors which provide selecting matching strings in the value of an attribute.
These CSS3 selectors already occurred less powerful as attribute selectors in CSS2.

# Syntax

Copy
[attribute*=value] {
    /* declarations */
}

# Example

Copy
[title*="example"] {
    border: 1px dashed blue;
}

0

Try example in CodePen

# Browser support

Platform Chrome Firefox Safari Edge Internet Explorer Opera
Desktop Yes (1) Yes (3) Yes (1) Yes (12) Yes (8) Yes (9.5)

Please wait a moment, the comments start loading now...
explorermozillachromesafariopera info external