Explaining the use of ^=
:
It signifies 'begins with..'
div[class^="test"] { }
This would be effective on an element like:
<div class="test and-some-class"></div>
<!-- only if the very first word in your class matches "test" -->
<!-- hence, class=" test something-else" won't match
To target with the CSS Selector:
It indicates 'contains..'
div[class*="test"] { }
This will be effective on
<div class="class test something-else"></div>
<!-- class name can be anything. "test" might appear anywhere within it -->
For more information, check out the following resource:
- CSS3 Attribute Selectors: Substring Matching