Anchored <img> linked to image source file?

Henry Pfeil hpfeil at psnarf.org
Sat Jan 12 17:23:07 UTC 2013


Just wondering why decorative icons/buttons are wrapped inside an anchor
tag. For example: https://fedoraproject.org/wiki/Releases/18/Schedule,
<div style="float: left; margin-left: -40px;"><a
href="/wiki/File:Note.png" class="image"><img alt="Note.png"
src="/w/uploads/thumb/c/cc/Note.png/35px-Note.png" width="35"
height="35" /></a></div>
When someone clicks on the decorative icon, they go to the image file,
in this example, https://fedoraproject.org/wiki/File:Note.png. That is
unexpected behavior and probably not what you want. <img> tags do not
need an anchor unless the image is part of the link to someplace you
want folks to go. According to w3.org, you may want to place those <img>
definitions in a style.css. (http://www.w3.org/wiki/HTML/Elements/img)

Since you don't intend File:Note.png to be a hyperlink, simply remove
the anchor tag wrapping it.
<img alt="Note.png" src="/w/uploads/thumb/c/cc/Note.png/35px-Note.png"
width="35" height="35">
Note the closing bracket is not '/>' but just '>'.

I think that syntax comes from the MediaWiki tools used to create the
page. Sorry to bother you, I should go pester the folks at MidaWiki?
http://validator.w3.org/ complains about other issues which are of no
concern to me. I was simply surprised when I ended up on a wiki page
dedicated to a decorative button.

-- 
Henry Pfeil
Principal Support Systems Analyst [retired]
University of Arizona



More information about the websites mailing list