Alt attribute
Encyclopedia
The alt attribute is used in HTML
HTML
HyperText Markup Language is the predominant markup language for web pages. HTML elements are the basic building-blocks of webpages....

 and XHTML
XHTML
XHTML is a family of XML markup languages that mirror or extend versions of the widely-used Hypertext Markup Language , the language in which web pages are written....

 documents to specify alternative text
Plain text
In computing, plain text is the contents of an ordinary sequential file readable as textual material without much processing, usually opposed to formatted text....

 (alt text) that is to be rendered
Rendering (computer graphics)
Rendering is the process of generating an image from a model , by means of computer programs. A scene file contains objects in a strictly defined language or data structure; it would contain geometry, viewpoint, texture, lighting, and shading information as a description of the virtual scene...

 when the element
HTML element
An HTML element is an individual component of an HTML document. HTML documents are composed of a tree of HTML elements and other nodes, such as text nodes. Each element can have attributes specified. Elements can also have content, including other elements and text. HTML elements represent...

 to which it is applied cannot be rendered. In HTML 4.01, the attribute is required for the img and area tags. It is optional for the input tag and the deprecated
Deprecation
In the process of authoring computer software, its standards or documentation, deprecation is a status applied to software features to indicate that they should be avoided, typically because they have been superseded...

 applet
Applet
In computing, an applet is any small application that performs one specific task that runs within the scope of a larger program, often as a plug-in. An applet typically also refers to Java applets, i.e., programs written in the Java programming language that are included in a web page...

tag.

The syntax of the alt attribute is:
...

...


or

Example

Here is an image for which the alt attribute is "In the sky flies a red flag with a white cross whose vertical bar is shifted toward the flagpole."

The HTML for this image might be something like the following:


In the sky flies a red flag with a white cross whose vertical bar is shifted toward the flagpole. src="http://upload.wikimedia.org/wikipedia/commons/thumb/8/83/Dannebrog.jpg/180px-Dannebrog.jpg"
width="180" height="135" />


A visually impaired reader using a screen reader
Screen reader
A screen reader is a software application that attempts to identify and interpret what is being displayed on the screen . This interpretation is then re-presented to the user with text-to-speech, sound icons, or a Braille output device...

 such as JAWS
JAWS (screen reader)
JAWS is a computer screen reader program in Microsoft Windows that allows blind and visually impaired users to read the screen either with a text-to-speech output or by a Refreshable Braille display....

 or Orca
Orca (assistive technology)
Orca is a free and open source, flexible, extensible assistive technology for people with visual impairments. Using various combinations of speech synthesis, braille, and magnification, Orca helps provide access to applications and toolkits that support the AT-SPI .The development of Orca has been...

 will hear the alt text in place of the image. A text browser such as Lynx
Lynx (web browser)
Lynx is a text-based web browser for use on cursor-addressable character cell terminals and is very configurable.-Usage:Browsing in Lynx consists of highlighting the chosen link using cursor keys, or having all links on a page numbered and entering the chosen link's number. Current versions support...

 will display the alt text instead of the image. A graphical browser typically will display only the image, and will display the alt text only if the user asks it to show the image's properties. Many graphical browsers can be configured to show the alt text instead of the image.

An alternative alt attribute value would be "The Danish flag".

Common misconceptions

The alt attribute is not supposed to literally describe the contents of the image http://www.cs.tut.fi/~jkorpela/html/alt.html. It is supposed to be an alternative for the image, usually stating its purpose. For example an image of a warning sign should not have alt text "a triangle with a yellow background, black border and an exclamation mark", but simply "Warning!". (Unless, of course, the purpose is actually to show what the warning symbol looks like.)
Internet Explorer
Internet Explorer
Windows Internet Explorer is a series of graphical web browsers developed by Microsoft and included as part of the Microsoft Windows line of operating systems, starting in 1995. It was first released as part of the add-on package Plus! for Windows 95 that year...

 7 and earlier render text in alt attributes as tooltip
Tooltip
The tooltip or infotip is a common graphical user interface element. It is used in conjunction with a cursor, usually a mouse pointer. The user hovers the cursor over an item, without clicking it, and a tooltip may appear—a small "hover box" with information about the item being hovered...

 text in standards non-compliant manner. This behavior led many web developer
Web developer
A web developer is a software developer or software engineer who specializes in, or is specifically engaged in, the development of World Wide Web applications, or distributed network applications that are run over HTTP from a web server to a web browser....

s to misuse alt when they wished to display tooltips containing additional information about images, instead of using the title attribute that was intended for that use. As of Internet Explorer 8
Internet Explorer 8
Windows Internet Explorer 8 is a web browser developed by Microsoft in the Internet Explorer browser series. The browser was released on March 19, 2009 for Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, and Windows 7. Both 32-bit and 64-bit builds are available...

 alt attributes no longer render as tooltips.

The alt attribute is commonly, but incorrectly, referred to as the "alt tag".

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK