snippetcssTip
Style links without a class
Viewed 0 times
linksstylewithoutcssclass
Problem
When styling injected or generated HTML content, you might not have access to the classes or IDs of the elements you want to style. This can become especially annoying when dealing with link elements. Luckily, you can use the
As a bonus tip, you can use the previous tip about selecting any link to further enhance this solution.
:not() selector with an appropriate attribute selector to check for the absence of a class and style links accordingly.As a bonus tip, you can use the previous tip about selecting any link to further enhance this solution.
Solution
a[href]:not([class]) {
color: #0077ff;
text-decoration: underline;
}Code Snippets
a[href]:not([class]) {
color: #0077ff;
text-decoration: underline;
}Context
From 30-seconds-of-code: style-default-links
Revisions (0)
No revisions yet.