Sent by Adam Kuehn on 28 February 2003 17:05
Joseph A Nagy Jr Enterprises wrote:
>>Thank you all who answered this message and the private answers I got to my
>>previous related message. However I started this thread specifically to find
>>out *why* you must specify as above. As Scott and others have stated, you
>>have to specify the image border that is caused by being between <a> on the
>>image. But you specify the text decoration that is caused by being between
>><a> on the <a>. This is illogical and I wanted to know if someone knew the
>>reasoning behind it. If I have both an image and some text in a <a>, instead
>>of specifying as illustrated above, it would be more efficient to specify:
>>
>>a:link { color: #000000; text-decoration: none; border: none }
>>
>>But if no one knows the reasoning behind this, I guess I'll have to chalk it
>>up to W3C vagaries. Thanks.
>
>I'm always looking to stick my neck out so I'll give it a try. Plain
>text anchors are just that. It doesn't matter if part of the anchor
>is an image or not. The border attribute for images doesn't apply to
>plain text. a:link, a:visited, a:active and a:hover are by default
>refering to plain text links, which have different attributes then
>images. Because of that, just including a:link { color: #000000;
>text-decoration: none; border: none } won't work because it will
>just apply to the plain text. a:link img {border: none;} is the best
>solution as it specifically says "apply this to the img". a:link {
>color: #000000; text-decoration: none; border: none } says "apply
>this to the plain text".
This is pretty much right. The underlying cause is not the W3C,
though, but browser defaults. By default, modern browsers use two
complementary link declarations to apply styles to links, one for
text, one for image links:
a {color: blue; text-decoration: underline;}
a img {border: 2px blue solid;}
These are artifacts from the early days of the web, when the browser
makers decided everything there was to decide about the appearance of
markup. Since these defaults come from time out of mind, modern
browser makers have decided to stick with them so that legacy pages
still look like they used to. As you've said, because images are
inline elements, but not text elements, they ignore the
text-decoration property. Early browsers didn't implement borders on
text, and that certainly isn't a reasonable default in any case, so
there is no border declaration directly on <a> elements.
So if you are blaming anyone for this, blame the folks at Netscape
back in - what, 1994? - who decided that linked images should have a
border and linked text should be underlined. Personally, though, I
think that was a pretty good decision. It's OK with me to type the
extra line in the CSS. At least now I can change those defaults if I
want to, and the separation makes a lot of other stuff possible.
--
-Adam Kuehn