CSS/Selectors/attribute selector/attribute$=value

From Web Education Community Group
< CSS‎ | Selectors
Jump to: navigation, search

[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>

Css3 selectors att 006.png

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