Forum Moderators: not2easy
Can anyone present a reason why this may or may not be a good idea?
Can anyone present a reason why this may or may not be a good idea?
Otherwise, as said above use both alt and title. Title is a valid way to describe a picture, not alt (introduced by IE, I think?)
You may also want to check for string limitation in "title" as I presume than a very very long title can be considered spam by some bots.
The site has been designed for accessibility, and I've found that wrapping <h> tags around image headers does the trick (engines pick up the title from the alt text and posit it into an <h> tag).
Just wondering if anyone had any experience using this method, and if so, what your findings were.
Title is a valid way to describe a picture, not alt (introduced by IE, I think?)
No, the title is not a valid way to describe the image. The alt attribute is the correct attribute to use when describing an image. IE did not introduce the alt attribute, it has been part of the html specification as far back as I can remember. ;)
The title attribute would be used to describe the destination of the image link if there were one. In this case, that doesn't seem to be the issue. When using images for <h> tags (which I don't do), you might do this...
<h1><img src="" alt=""></h1> If the image was linked, you might do something like this...
<h1><a href="" title=""><img src="" alt=""></h1> There are also other methods to optimize an image that is being used as an <h> tag.
engines pick up the title from the alt text
My experience is that the alt attribute content gets indexed but not weighted as heavily as straight text inside the <h1>. The weighting that search engines give <h1> goes up and down too, sometimes almost to the level of plain text. But when the dials are turned higher, it's good to have straight text in there -- so I prefer image replacement methods where the image is used as a background image.
Create you nice header image. (header.png)
In your page:
<div id="header">
<h1>My Heading</h1>
</div>
in your CSS:
#header {
background-image: url(path/to/header.png);
background-repeat:no-repeat
width: XXpx;
height:XXpx;
}
#header h1 {display:none}
Done!
What this does is set your header as the background image of a <div> (sized to the width/height of your image), and simply doesn't display the <h> tag inside the <div>
This means you page is accessible to screen readers, people without CSS, search engines, etc, but still looks visually correct to the regular visitor.
Easy, huh?
Easy, huh?
Yeah, but the code is so ugly... ;-) Plus, if you search around, I believe that you will find that text with the style 'display:none;' applied to it is not read by screenreaders (or not consistently by all screenreaders in any case; this was one of the major factors in 'display:none;' dropping out of use in image replacement techniques very quickly).
As mentioned above, there are lots of image replacement techniques, but here's a simple example (original sources here [moronicbajebus.com] and here [kryogenix.org]) that avoids the excess markup and survives most permutations of browser settings intact:
<h1 id="loremHeader" title="Lorem ipsum dolor">Lorem ipsum dolor</h1>
/* Assumes a 150px x 25px image. Note that this method will need to be 'corrected' for both the IE 5 Win series and IE 5 Mac */
#loremHeader {
width:150px
height:0;
overflow:hidden;
font-size:12px;
background:transparent url(path/to/image.gif) no-repeat 0 0;
padding-top:25px;
}
This method works whether or not css is available or images are 'on'. Its main drawbacks are that a) in common with all image replacement methods, the background image is not resizable text, and b) the actual html text may not be readable since it's necessary to fit it into a box of a specified size. This means that, when images are off, the text may either not be resizeable (in IE Win) or may not be entirely visible if the text is increased in size (since we've specified 'overflow:hidden;'). In the example I've given, this problem may be imperfectly overcome by the use of the title attribute in the h1.
-b