HTML CSS examples for CSS Selector:attribute start with value
The [attribute^=value] selector selects elements whose attribute value begins with the value.
Set a background color on all elements that have a class attribute value that begins with "test":
<!DOCTYPE html> <html> <head> <style> [class^="test"] { background: #ffff00; } </style><!-- w w w.j a v a 2 s . co m--> </head> <body> <div class="first_test">The first div element.</div> <div class="second">The second div element.</div> <div class="test">The third div element.</div> <p class="test">This is some text in a paragraph.</p> </body> </html>