e n | c k m a said:
Is it okay to use the alt text of an image for the text of an <hx>?
I'm not sure I understand the question correctly, but if it means
"if I use an image as a first level heading, is it appropriate to put the
<h1><img src="images/blah.gif" width="200" height="45" alt="This is a
heading!"></h1>
Right. When it is logically a 1st level heading said:
There is no specified behavior that it _should_ cause but it _may_
have various effects, such as
- search engines may treat the alt text as heading text (I'm afraid
they currently don't)
- graphic browsers, when not rendering the image for some reason (e.g.
image loading disabled in settings), may render the alt text the
same way the render normal <h1> text (e.g., Mozilla does so)
- similarly, text browsers may render it in heading style.
Note that although <h1> does not affect the image rendering when the
image is shown, it still (typically) causes margins above and below, so
to achieve the same visual effect in that case as without <h1>, use
h1 { margin: 0; }
in a stylesheet. Unfortunately there is no way saying "apply this CSS
rule if and only if you render this image (and not the alt text)", but
this isn't usually a big problem here in practice.