Issue
I understand :link allows to select unvisited elements, and I'm aware of the LoVe-HAte trick to remember the order in which order to put the various link pseudo-classes. But in practice I always style my links like this:
a {
/* common styles for all links, regardless of state */
/* this includes unvisited links, and thus a:link */
}
a:visited {
/* specific styles for visited links */
}
a:hover {}
a:active {}
Since a link is either visited or unvisited, this covers all possible cases, and I really don't understand what the :link pseudo-class adds to the table.
Am I missing something?
Solution
The a:link selector lets you set the styles on <a> tags that actually link somewhere.
Bare <a> tags without an href attribute are traditionally used as markers in a document; setting the location to document.html#foo will jump you to wherever <a id="foo"> is in the document. It is, after all, called an "anchor" tag for a reason.
Traditional HTML may look something like this:
a {
color: green;
}
a:link {
color: red;
}
<h2>Navigation</h2>
<a href="#ch1">Chapter 1 (red :link)</a>
...
<h3><a id="ch1">Chapter 1 (green anchor)</a></h3>
<p>It was the best of times...</p>
Subsequent HTML standards let you use the document.html#thing syntax to jump to any element with the attribute id="thing", but it wasn't always the case.
Answered By - amphetamachine
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.