I need to use attribute selector in css to change link on different color and image, but it does not work.
I have this html:
<a href="/manual.pdf">A PDF File</a>
And this css:
a {
display: block;
height: 25px;
padding-left: 25px;
color:#333;
font: bold 15px Tahoma;
text-decoration: none;
}
a[href='.pdf'] { background: red; }
Why isn’t the background red?
Use the $ after your href. This will make the attribute value to match the end of the string.
JSFiddle: http://jsfiddle.net/UG9ud/
source: http://www.w3.org/TR/selectors/