English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Guide CSS

CSS @règles (RULES)

Complète liste des attributs CSS

CSS3 [attribute^=value] Selector

Represents elements that have an attribute named attribute and whose attribute value starts with "value".

Complete CSS selector reference manual

Online example

Set the background color of all div elements with the class attribute value starting with "test":

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>Basic Tutorial(oldtoolbag.com)</title> 
<style> 
div[class^="test"]
{
background:#ff9900;
}
</style>
</head>
<body>
<div class="first_test">The1A DIV element.</div>
<div class="second">The2A DIV element.</div>
<div class="test">The3A DIV element.</div>
<p class="test">This is a common text paragraph.</p>
</body>
</html>
Test and see ‹/›

Definition and usage

The [attribute^=value] Selector matches elements whose attribute value starts with the specified value.

Browser compatibility

IEFirefoxOperaChromeSafari

All mainstream browsers support[attribute^=value] Selector.

Note: [attribute^=value] in IE8Running in the middle, it must declare<!DOCTYPE>

Online example

Set the background color of all elements with the class attribute value starting with "test":

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>Basic Tutorial(oldtoolbag.com)</title> 
<style> 
[class^="test"]
{
background:#ff9900;
}
</style>
</head>
<body>
<div class="first_test">The1A DIV element.</div>
<div class="second">The2A DIV element.</div>
<div class="test">The3A DIV element.</div>
<p class="test">This is a common text paragraph.</p>
</body>
</html>
Test and see ‹/›

Complete CSS selector reference manual