The [attribute*="value"] selector is used to select elements whose attribute value contains a specified value. The following example selects all elements with a class attribute value that contains "te":
HTML file: | Displayed by browser: |
---|---|
<style>
[class*="te"] { background: yellow; } </style> <body> <div class="first_test">The first div element.</div> <div class="second">The second div element.</div> <div class="my-third">The third div element.</div> <p class="mytest">This is some text in a paragraph.</p> </body> |
The first div element.
The second div element.
The third div element.
This is some text in a paragraph. |
Note: The value does not have to be a whole word.