Forum Moderators: not2easy
Attribute definitions
alt = text [CS]
For user agents that cannot display images, forms, or applets, this
attribute specifies alternate text... Several non-textual elements
(IMG, AREA, APPLET, and INPUT) let authors specify alternate
text to serve as content when the element cannot be rendered
normally...The alt attribute must be specified for the IMG and AREA
elements. It is optional for the INPUT and APPLET elements.[w3.org...]
You can, however, use a title attribute in an anchor tag, and that should generate a tool-tip when someone hovers over the anchor element.
So it is wise to use the title attribute for anchors to help non-visual readers.
But what about images in the case where they exist in the background? I came up with an idea to do something like this:
.alt
{
// indent outside the box
// display: none;
// etc.
}
<div id="logo">
<span class="alt">This is the logo</span>
</div>
Do you know of any alt css tricks that is better than others?
The only time I would background a critical content image is when it's serving as a navigation button with text in a non-standard font. In that case, I would use an image replacement [webmasterworld.com] technique, similar to what you describe.
But I wouldn't go overboard and start .alt-ing every background image on your page. Remember, an image only needs an alt attribute if it says something important that visitors using screen readers or surfing with styles off will not get without it.
cEM
No, an image always needs to have a alt="" attribute.
You mean an <img> always needs to have an alt attribute. In the case of a background image, not only does it not need one to validate, but you can't give it one, since alt is an attribute assigned to an element in the markup (which a background image is not).
cEM