Example 1 — Style Links Ending in .html
Underline only page links whose href ends with .html.
<style>
a[href$=".html"] {
color: #1d4ed8;
font-weight: 600;
text-decoration: underline;
}
</style>
<a href="about.html">About</a>
<a href="https://example.com/blog">Blog</a> How It Works
- Target the attribute. Use
hrefon anchors. - Require the suffix.
$=".html"matches only values that end that way. - Style matches. About is underlined; the blog URL is not.
- Exact end.
page.html?x=1would not match because it does not end with.html.

