32.7 Providing (or omitting) alternate text for images

Most current browsers display the content of the alt attribute of an <img> tag only when the image itself is not displayed.

Note:  To show a text value in a tooltip when you move the pointer over an image, use the title attribute instead.

By default, if you do not provide alt text for an image, DITA2Go includes an empty alt value, to satisfy validators. To omit empty alt attribute values:

[Graphics]
; AllowEmptyAlt = Yes (default) or No, omit empty alt attributes.
AllowEmptyAlt = No

You can specify a value for the <img> tag alt attribute in any of the following ways:

Include the text in a paragraph

Insert the text with a PI marker

Assign the text to the graphic file.

Include the text in a paragraph

To use a dedicated paragraph format for alternate text, place a paragraph containing the text in your DITA document, just before the <image> tag, and assign the following properties to the paragraph format:

[HTMLParaStyles]
AltParaFmt = Alt Delete

The Delete property prevents the alternate text from appearing as part of the HTML output. See §34.2.2 Assigning WAI image attributes with dedicated formats.

To use a character format instead of a paragraph format to provide a value for the alt attribute, assign it in [HTMLCharStyles] instead of in [HTMLParaStyles].

Insert the text with a PI marker

To provide alternate text with a PI marker, insert a PI marker of type GraphAlt in your DITA document, just before the <image> tag. The content of the GraphAlt PI marker becomes the value of the alt attribute for the next image. See §34.2.3 Assigning WAI image attributes with PI markers and §38.3 Adding attributes with PI markers.

Assign the text to the graphic file

To assign alternate text to the graphic file (for example):

[GraphALT]
; Graphic file name (with or without extension) = desired alt text
ch01f853.gif = Schematic of tuner

Previous Topic:  32.6 Specifying HTML image attributes

Next Topic:  32.8 Scaling images for HTML

Parent Topic:  32. Including graphics in HTML

Sibling Topics:

32.1 Locating graphics files for HTML

32.2 Specifying options for HTML graphics

32.3 Omitting graphics from HTML output

32.4 Selecting and modifying graphics

32.5 Positioning graphics in HTML output

32.6 Specifying HTML image attributes

32.8 Scaling images for HTML

32.9 Creating image maps for HTML

32.10 Supplying a background image or watermark

Table of ContentsIndex