attribute

Attribute Starts With Selector

Selects elements whose named attribute begins with the specified substring. Useful for prefixed values like URLs or namespaced identifiers.

[attr^="value"]

Example

a[href^="https://"] { color: green; } /* HTML: <a href="https://x.com">Secure</a> */

✓ Matches

  • <a href="https://a.com">a</a>
  • <a href="https://b.io/x">b</a>
  • <a href="https://x">c</a>

✗ Does not match

  • <a href="http://a.com">a</a>
  • <a href="/local">b</a>

Browser support

Universal support in all browsers since CSS3.

Related selectors

← All CSS selectors · CSS selectors cheat sheet