CSS image replacement is a Web design technique that uses
Cascading Style Sheets to replace text on a Web page with an image containing that text. It is intended to keep the page accessible to users of
screen reader
A screen reader is a form of assistive technology (AT) that renders text and image content as speech or braille output. Screen readers are essential to people who are blind, and are useful to people who are visually impaired, illiterate, or hav ...
s, text-only
web browser
A web browser is application software for accessing websites. When a user requests a web page from a particular website, the browser retrieves its files from a web server and then displays the page on the user's screen. Browsers are used on ...
s, or other browsers where support for images or style sheets is either disabled or nonexistent, while allowing the image to differ between styles. Also named Fahrner image replacement for Todd Fahrner, one of the persons originally credited with the idea of image replacement in 2003.
[
]
With the introduction of CSS web font support in all major web browsers, CSS image replacement is now little used.
Motivation
The typical method of inserting an image in an
HTML
The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScri ...
document is via the
<img>
tag. This method has its drawbacks with regards to accessibility and flexibility, however:
* While the
alt
attribute is designed for providing a textual representation of the image content, this precludes the use of HTML markup in the textual representation and causes problems with some search robots.
* Using the
<img>
tag to show text is presentational; many Web designers argue that presentational elements should be separated from HTML content by placing the former in a CSS style sheet.
* Images referenced using an
<img>
tag cannot be easily changed via CSS, causing problems with alternative stylesheets.
Fahrner image replacement was devised to rectify these issues.
Implementations
The original Image Replacement implementation
described by
Douglas Bowman
Douglas may refer to:
People
* Douglas (given name)
* Douglas (surname)
Animals
*Douglas (parrot), macaw that starred as the parrot ''Rosalinda'' in Pippi Longstocking
* Douglas the camel, a camel in the Confederate Army in the American Civil ...
used a heading, inside of which was a
<span>
element containing the text of the heading:
Through style sheets, the heading was then given a background containing the desired image, and the
<span>
hidden by setting its
display
CSS property to
none
:
#firHeader
#firHeader span
It was soon discovered, however, that this method caused some screen readers to skip over the heading entirely, as they would not read any text that had a
display
property of
none
. The later Phark method, developed by
Mike Rundle in 2003, instead used the
text-indent
property to push the text out of the image's area, addressing this issue:
#firHeader
The Phark method had its own problems, however; in visual browsers where CSS was on but images off, nothing would display.
Also in 2003,
Dave Shea's eponymous Shea method solves both of the issues earlier mentioned, at the cost of an extra
<span>
:
By absolutely positioning an empty
<span>
over the text element, the text is effectively hidden. If the image fails to load, the text behind it is still displayed. For this reason, images with transparency cannot be used with the Shea method.
#header
#header span
Over a dozen different methods has since been developed with varying degree of compatibility and complexity.
[{{Cite web
, title = The Image Replacement Museum
, author = Mosley
, first = Marie
, website = CSS-Tricks
, date = 2015-11-03
, access-date = 30 March 2019
, url = https://css-tricks.com/the-image-replacement-museum/
, quote =
]
References
External links
Revised Image Replacementnbsp;– an overview of the various FIR techniques by
Dave Shea
Ultimate Image Replacementnbsp;– a comprehensive image replacement technique by
Jesse Schoberg
Jesse may refer to:
People and fictional characters
* Jesse (biblical figure), father of David in the Bible.
* Jesse (given name), including a list of people and fictional characters
* Jesse (surname), a list of people
Music
* ''Jesse'' (a ...
Web design
Cascading Style Sheets
Obsolete technologies