CSS/Selectors/attribute selector/attribute$=value

From W3C Wiki
< CSS‎ | Selectors

[attributename$="val"]

This selector represents an element with the "attributename" attribute whose value ends with the suffix "val".


Syntax

elementname[attributename$="val"]{ properties }


Point, Note

  • If "val" is the empty string then the selector does not represent anything.


Example

[style.css]

 a[href$=".pdf"]::after{
   content: "(Note that is a link to PDF.)";
 }

[index.html]

<body>
  <p>Go to <a href="http://www.example.com/example.pdf">documentation.</a><p>
</body>

CSS defines the attribute selector in 6.3.2. Substring matching attribute selectors.