How are hyperlinks created in DITA XML?
Creating hyperlinks in DITA XML is essential for connecting and cross-referencing different topics, providing readers with a seamless and navigable documentation experience. DITA offers several methods to create hyperlinks, allowing authors to link content efficiently. Here’s an overview of how hyperlinks are established in DITA XML.
Inline Linking
Inline linking is a straightforward way to create hyperlinks within DITA content. To establish a hyperlink, you can use the <ph>
(short for “phrase”) element with the keyref
or conref
attribute, specifying the target topic or element you want to link to. This method is useful for creating context-specific links directly within the content. For example, you can link to definitions or related topics by referencing their IDs using the keyref
attribute.
Key Reference Links
DITA XML also provides the <xref>
element for key references. The <xref>
element is a more structured way to create links. It allows you to reference topics or elements using a key reference identifier. This method is commonly used for cross-referencing topics or sections within your documentation. Authors can specify the target using the keyref
attribute and include the text to display as the link using the <linktext>
element.
Example:
Here’s an example of how hyperlinks are created in DITA XML using inline linking:
<ph keyref="glossary_definition" id="inline-link"><term>hyperlink</term></ph>
In this example, the term “hyperlink” is linked to a glossary definition using the keyref
attribute.