How are hyperlinks created in DITA topics?

Hyperlinks are essential in DITA topics to connect content and provide easy navigation. They allow readers to access related information, external resources, or other sections within a topic.

Hyperlinks are created in DITA by linking elements, setting a target uniform resource identifier, enclosing link text, and linking to anchors.

Linking Elements:

DITA provides several elements for creating hyperlinks. The most commonly used ones are:

  • <link>: Used for creating simple links to other topics or web resources.
  • <xref>: Specifically designed for cross-referencing within DITA topics, allowing links to sections or elements within the same or different topics.
  • <image>: Allows linking from an image to a target.
  • <topicref>: Used in DITA maps to reference topics.

Target URI:

The href or conref attribute within these elements specifies the target Uniform Resource Identifier (URI), which can be a relative path to another topic or an absolute URL.

Link Text:

Hyperlinks are created by enclosing link text within the chosen linking element. This text serves as the clickable link, and it may describe the linked content or provide context.

Linking to Anchors:

To link to a specific section or element within a topic, an anchor can be used with the <xref> element. Anchors are defined in the target section, and the keyref attribute is used for linking.


Here’s an example of creating hyperlinks in a DITA topic:

<p>This is a <link href="">link to an external website</link>.</p>

<p>For more details, see the <xref href="another-topic.dita">related topic</xref>.</p>

<image href="image.jpg">
  <alt>Click this image</alt>

In this example:

  • The first paragraph contains a hyperlink to an external website using the <link> element.
  • The second paragraph demonstrates cross-referencing to another DITA topic using the <xref> element.
  • The last example links from an image using the <image> element.