What's considered a best practice in the following situation?
i have menu via a UL, but for one item there is currently there is no text or image inside the anchor tag. so it looks like this:
<li><a id="home"></a></li>
instead the anchor tag is styled and uses a background image. i did this because i wanted to use a:hover to change the background image (instead of javascript) and also wanted use css transistion.
but is that a bad practice, having an empty <a> tag???,
thanks
in the past i'd put a transparent gif in there or something but that seems kind of lame
Naturally, it's best practice not to have an empty <a>nchor tag in your code - if only because the search engines might see it as a hidden link. If you must include the tag in your code for some reason, it's best to omit the 'href' attribute for that reason. Overall, I'd suggest looking for ways to omit the tag entirely until it's appropriate to include it for users.
For accessibility reasons, I say it is very bad to have an empty anchor tag in your code. People using a screen reader etc would not be able to read the link. The simplest solution would probably by to wrap the anchor around an image tag instead, but be sure to include an alt attribute in the image tag.
"If a picture is worth a thousand words, how come we need to limit our alt tag to 50 characters?"
Bookmarks