<xref>: What steps are involved in creating cross-references to other locations within the same or different DITA topics using the <xref> element?

The <xref> element in DITA is used to create cross-references to other locations within the same or different DITA topics, enhancing the navigational structure and coherence of your documentation.

Creating Cross-References

To create a cross-reference using the <xref> element, follow these steps:

  1. Specify the target location by using the href attribute, which can include a URL or a fragment identifier to reference an element within the same topic or a different one.
  2. Include a reference type using the type attribute, such as “basic” for a simple link, or “title” to link to a topic’s title.
  3. Optionally, you can add descriptive text within the <xref> element to provide context to the reader.

Here’s an example of a cross-reference to a different topic:


For more details, refer to the <xref href="other_topic.dita" type="basic">other topic</xref>.

Linking to Fragments

You can also create cross-references to specific elements within the same topic by using fragment identifiers. For example:


Please see the <xref href="#section1" type="basic">first section</xref> for details.

In this case, the fragment identifier “#section1” points to a section within the same topic, allowing you to create intra-topic cross-references.