Jump to content

CSS image replacement

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by MER-C (talk | contribs) at 02:28, 18 November 2006 (Prodded). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Fahrner Image Replacement is a web design method that replaces HTML text on a page with an image file containing said text. This keeps the web page accessible for screen readers, text browsers, and those browsing with style sheets or images turned off.

The original coding used a heading with the background of desired image, and a span with the actual text of the page. Then through style sheets the span was set to "display:none" to prevent it from showing up.

Code Example:

<h3 id="firHeader"><span>Sample Headline</span></h3> #firHeader { width: 300px; height: 50px; background: #fff url(firHeader.gif) top left no-repeat; } #firHeader span { display: none; }

This however was not with out its downfalls, as it was discovered some screen readers will not read any element that was set to "display:none".

Because of this, newer methods were developed

The Phark Method again uses text indent to push the text out of the display box, and then hides all the overflow. This solves screen reading problems, but doesn't address a situation where css is on, but images are turned off (or fail to load).

Code Example:

<h3 id="header"> Revised Image Replacement </h3> /* css */ #header { text-indent: -5000px; background: url(sample-opaque.gif); height: 25px; }

Shea Method

The Shea Method solves both images/css on/off problems and screen reader issues, but does require one extra span element. The span element is absolutely positioned over the text element, effectively hiding it. If the image fails to load the text behind it is still displayed.

Code Example:

<h3 id="header" title="Revised Image Replacement"> <span></span>Revised Image Replacement </h3> /* css */ #header { width: 329px; height: 25px; position: relative; } #header span { background: url(sample-opaque.gif) no-repeat; position: absolute; width: 100%; height: 100%; }