A better image replacement technique
Over on Kryogenix, Stuart has solved the CSS image replacement problem with some clever application of the overflow: hidden; property. The Fahrner Image Replacement technique is often used to replace a heading with a background image (see most of the designs in the CSS Zen Garden for examples), but has the disadvantages that it requires an additional <span> tag to be added to the code and that some screen readers which follow the display: none; directive skip straight over the replaced text without reading it. Stuart’s new technique solves both problems, and works in modern browsers from IE 5/Win upwards.
Shouldn't that be display:none;? But if that's correct these screen readers don't support CSS well, 'cause if you want to hide CSS from an aural browser it should be speak:none;.
Anne van Kesteren - 5th August 2003 11:50 - #
Simon Willison - 5th August 2003 11:55 - #
Very nice. Well spotted.
Isn't one of the biggest problems with screen readers that almost none of them support CSS? Excepting EMACSpeak which is not exactly mainstream.
Simon Proctor - 5th August 2003 12:26 - #
display: none; applies to all media. The problem with screen readers that sit on top of normal browsers is that media-specific styling is applied wrongly. So this does exactly the wrong thing:
@media screen { .foo { display: none; } } @media aural { .foo { display: block; } }(What - no <br /> or <pre>?)
Jim Dabell - 5th August 2003 12:57 - #
Yup, seems to work fine.
Simon Willison - 5th August 2003 14:12 - #
Why don't you use
pre{width:20em;overflow:auto;}, something similar works fine at my blog (Mozilla that is, IE isn't good at it, but it's better than this).An aural browser shouldn't have anything to do with the display property. But I think we are now talking about a screen reader. Those are very difficult I think. They only read from the screen and not you source code with al that "clever" css in there.
Simon you cookies are broken or something, can't you do it with PHP, instead of JavaScript.
Anne van Kesteren - 5th August 2003 15:29 - #
Dave S. - 5th August 2003 15:31 - #
Tom Gilder uses a simlar technique for adding skip links:
http://blog.tom.me.uk/
(press tab to start going through as a keyboard user, and suddenly the skip link appears!)
That is a great way of providing visible skip links without disturbing the visual appearance for visual browsers.
With regards to hiding things visually but providing them to screenreader users, most screenreaders (well, Jaws at least) do not read CSS from an @import statement.
This was discussed on Webaim, unfortunately the threads got a bit messed up, but these summarise fairly well:
My reply to Peter-Paul Koch about differentiating general IE users and screen reader users.
David Hoffman replying about the next Jaws version.
My last post on the topic.
David Hoffman mentioned that the next version of Jaws may read CSS from an @import, but I tried to discourage this... I'd be interested on what other people here think of that thread.
AlastairC - 5th August 2003 15:53 - #
Perhaps Jaws could use DOCTYPE switching? For pages with a valid, modern DOCTYPE it'd disregard styles applied to "screen", for other pages it'd carry on with its current approach. (I don't understand why it hasn't always just disregarded visual styles anyway, that works fine for text based browsers)
Matt Round - 5th August 2003 19:55 - #
From Joe Clark's originating WAI mailing list, IBM's Homepage Reader may be the culprit.
Isofarro - 6th August 2003 09:16 - #
Nathan - 6th August 2003 15:50 - #
AFAIK, Homepage reader is a speach-browser (i.e. will 'render' the HTML itself), but Jaws & Windows eyes sit on top of the browser, typically Internet Explorer.
Where the techniques fall down is for people who have CSS but not images (e.g. on a slow connection). Ian Lloyd made that challenge, to see if there is a technique that works in that situtation to.
(Oh, and I noticed the failing with Opera 7, but I've not had time to investigate.)
AlastairC - 6th August 2003 16:44 - #
Yeah, I saw that too. If you look at the source you will see that the author forgot to put a closing comment tag within his style tag. Nice technique though. I am gonna test it some more.
Marc R - 6th August 2003 18:34 - #
Simon Willison - 6th August 2003 20:07 - #
Ben de Groot - 7th August 2003 01:59 - #
Levin - 13th August 2003 23:15 - #