<keytext>

Key text is variable or link text that is used when resolving key references. It also specifies alternate text for images that are referenced by keys.

Processing expectations

See Processing key references to generate text or link text.

Content model

(Text | <cite> | <data> | <keyword> | <ph> | <strong> | <em> | <b> | <i> | <line-through> | <overline> | <sup> | <sub> | <tt> | <u> | <q> | <term> | <text> | <tm> )*

Attributes

The following attributes are available on this element: universal attributes.

The following attributes are available on this element: universal attributes.

Examples

This section is non-normative.

This section contains examples of how the <keytext> element can be used.

Example 1. Simple example

The following code sample shows a variable-text definition that includes highlighting elements:

<keydef keys="company-name">
  <topicmeta>
    <keytext translate="no">
      <i>Super</i> Widget Squared<sup>2</sup>
    </keytext>
  </topicmeta>
</keydef>
Example 2. Alternate text for an image

DITA implementations often reference images using keys. In such cases, the <keytext> element provides the alternate text for the image. The following code sample shows the markup for the <keytext> element:

<keydef keys="company-logo" href="images/logo.jpg" format="jpg">
  <topicmeta>
    <keytext>Acme Widgets logo</keytext>
  </topicmeta>
</keydef>

The image can be referenced by <image keyref="company-logo"/>. When rendered to mediums that support alternate text, the effective alternative text for the image is "Acme Widgets logo" as though a literal <alt> element had been a child of the <image>.

Example 3. Processing logic

The following code sample shows a key definition that includes several elements within the <topicmeta> element:

<keydef href="http://www.example.com" keys="company-name" format="html" scope="external">
  <topicmeta>
    <keytext>Acme Tools</keytext>
    <navtitle>Acme Tools web site</navtitle>
    <linktitle>Acme Tools Web Portal</linktitle>
  </topicmeta>
</keydef>

Once processed, the effective text content of both <ph keyref="company-name"/> and <xref keyref="company-name"/> is Acme Tools. This is because of the rules for how processors resolve key references to generate text or link text.

To set distinct text values for both the company name and the link text that is associated with the company Web site, use two different keys.