Language
日本語
English

Caution

JavaScript is disabled in your browser.
This site uses JavaScript for features such as search.
For the best experience, please enable JavaScript before browsing this site.

CSS Dictionary

  1. Home
  2. CSS Dictionary
  3. [CSS Selector] E[foo^="bar"]

[CSS Selector] E[foo^="bar"]

Using 'selector[attribute^=value]', you can apply styles only to elements where a specific attribute's value starts with the given string. This does not work in IE6 and below.

For example, if the value is function, it would match strings like fu, func, or funct — anything that appears at the beginning of the value.

Sample Code

p[title^=hoge] { color: red;} /* Applies to p elements whose title attribute value starts with 'hoge'. */
p[title^=hoge1] { color: blue;} /* Applies to all p elements whose title attribute value starts with 'hoge1'. */
[title^=Hatsune-Miku] { color: green;} /* Non-ASCII characters work here too. */

Browser Preview

p[title^=hoge] { color: red;} /* Applies to p elements whose title attribute value starts with 'hoge'. */
p[title^=hoge1] { color: blue;} /* Applies to all p elements whose title attribute value starts with 'hoge1'. */
[title^=Hatsune-Miku] { color: green;} /* Non-ASCII characters work here too. */

<p title="hoge">This is a p element. The title is set to 'hoge'.</p>
<p title="hoge1hoge fuga">This is a p element. The title is set to 'hoge1hoge fuga'.</p>
<p title="Hatsune-Miku and IA">This is a p element. The title attribute is set to 'Hatsune-Miku and IA'.</p>

Browser Compatibility

Chrome Chrome
1+
Firefox Firefox
1+
Safari Safari
3+
2 and below ×
Edge Edge
12+
Supported in all versions.
IE IE
11
10
9
8
7
6 ×
Opera Opera
9+
8 and below ×
iOS Safari iOS Safari
1+
Android Android Browser
4.4+
3 and below ×
Chrome Android Chrome Android
Latest
Same support as desktop.
Firefox Android Firefox Android
Latest
Same support as desktop.

※ Version data is based on MDN.

If you find any errors or copyright issues, please .