<link>
A link is a reference to another DITA topic or a non-DITA resource.
Processing expectations
When displayed, links are typically sorted based on their attributes, which define the type or role of the link target in relation to the current topic.
Content model
<linktext>
?,
<desc>
?
- Optional
<linktext>
- Optional
<desc>
Attributes
The following attributes are available on this element: link-relationship attributes, universal
attributes, @keyref
, @otherrole
, and @role
.
The following attributes are available on this element: universal attributes and the attributes defined below.
@format
(link-relationship attributes)- Specifies the format of the resource that is referenced. See The format attribute for detailed information on supported values and processing implications.
@href
(link-relationship attributes)- Specifies a reference to a resource. See The href attribute for detailed information on supported values and processing implications.
@keyref
- Specifies a key name that acts as a redirectable reference based on a key definition within a map. See The keyref attribute for information on using this attribute.
@otherrole
- Specifies an alternate role for a link relationship when the
@role
attribute is set to other. @role
- Specifies the role that a linked topic plays in relationship
with the current topic.
For example, in a parent/child relationship, the role would be parent when the target is the parent of the current topic, and child when the target is the child of the current topic. This can be used to sort and classify links when rendering.
The following values are valid:
- ancestor
- Indicates a link to a topic above the parent topic.
- child
- Indicates a link to a direct child such as a directly nested or dependent topic.
- cousin
- Indicates a link to another topic in the same hierarchy that is not a parent, child, sibling, next, or previous.
- descendant
- Indicates a link to a topic below a child topic.
- friend
- Indicates a link to a similar topic that is not necessarily part of the same hierarchy.
- next
- Indicates a link to the next topic in a sequence.
- other
- Indicates any other kind of relationship or role. The
type of role is specified as the value for the
@otherrole
attribute. - parent
- Indicates a link to a topic that is a parent of the current topic.
- previous
- Indicates a link to the previous topic in a sequence.
- sibling
- Indicates a link between two children of the same parent topic.
- -dita-use-conref-target
- See Using the -dita-use-conref-target value for more information.
@scope
(link-relationship attributes)- Specifies the closeness of the relationship between the
current document and the referenced resource. The following values are valid:
local, peer,
external, and
-dita-use-conref-target.
See The scope attribute for detailed information on supported values and processing implications.
@type
(link-relationship attributes)- Describes the target of a reference. See The type attribute for detailed information on supported values and processing implications.
Example
This section is non-normative.
The following code sample shows a simple collection of links in a
DITA topic. There are four links: two to DITA topics and two to to
HTML pages. The <linktext>
element provides
link text for the HTML pages, and the <desc>
element contain text that describes the resource that the link
targets.
<related-links>
<link href="covid-19.dita"/>
<link href="covid-19-testing.dita"/>
<link format="html" href="covid-19-nc.html">
<linktext>COVID-19 in North Carolina</linktext>
</link>
<link format="html" href="239fh49.html#resources">
<linktext>Public health resources in Durham, NC</linktext>
<desc>When you work as a contact tracer, you need to know ...</desc>
</link>
</related-links>