snippetcssTip
Select any link with CSS
Viewed 0 times
linkanywithcssselect
Problem
Styling links with CSS is considered straightforward, with most developers using the
One important note is that using
:link and :visited pseudo-classes. While this solution is very common, there's a less verbose alternative in the form of the :any-link pseudo-class. This pseudo-class selects all links, regardless of whether they have been visited or not. Thus, it acts as a catch-all for all links on the page.One important note is that using
:any-link is different to using the [href] attribute selector. The :any-link pseudo-class does not select empty links, whereas the [href] attribute selector does.Solution
Implementation for Select any link with CSS:
See the code snippet for the complete implementation.
:any-link {
color: #0444f6;
}See the code snippet for the complete implementation.
Code Snippets
:any-link {
color: #0444f6;
}Context
From 30-seconds-of-code: select-any-link
Revisions (0)
No revisions yet.