[attribute$=value], attribute value ends with - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:attribute value ends with

Introduction

The [attribute$=value] selector selects elements whose attribute value ends with the specified value.

Example

The following code shows how to add a background color on all elements whose a class attribute value ends with "test":

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
[class$="test"] {
    background: #ffff00;
}
</style><!--from   ww w. j a v  a2s  . c  o  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>

Related Tutorials