CSS Selector - How to use CSS ends with Selector [attribute$=value]








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

Summary

CSS Version
3

CSS Syntax

[attribute$=value] { 
   style properties 
}

Browser compatibility

[attribute$=value] Yes 7.0 Yes Yes Yes




Example

An example showing how to use [attribute$=value] CSS selector.

<!DOCTYPE html>
<html>
<head>
<style> 
div[class$="_red"]
{<!--from  w  w w  . ja  v a  2 s. co  m-->
   background:red;
}
</style>
</head>
<body>
    <div class="div_red">div element.</div>
    <p class="p_red">a paragraph.</p>
</body>
</html>

Click to view the demo