1

Sometimes, we use the rel attribute do convey meaning to a link to a specific page or page fragment, like so:

<link rel="author" href="https://example.com/humans.txt">
<a rel="bookmark" href="https://example.com/page#thing">thing</a>

So far, so good.

Case

Now say I have a glossary page, https://example.com/glossary, and on that page, I have a definition list with a bunch of terms:

<dl id="dictionary">
  <dt id="foo">foo</dt>
  <dd>A foo is not a <a href="#bar">bar</a>.</dd>
  <dt id="bar">bar</dt>
  <dd>A metric unit of pressure that serves alcoholic beverages.</dd>
</dl>

This makes we wonder what the proper/best way is to link to the glossary, and to a specific term in said glossary. I’ve come up with the following options:

For the glossary:

1. <link rel="glossary" href="https://example.com/glossary">
2. <link rel="glossary" href="https://example.com/glossary#dictionary">

For a specific term:

1. <a rel="bookmark" href="https://example.com/glossary#bar">bar</a>
2. <a rel="glossary" href="https://example.com/glossary#bar">bar</a>
3. <a rel="bookmark glossary" href="https://example.com/glossary#bar">bar</a>
4. <a href="https://example.com/glossary#bar">bar</a>

What do you think are the best options, and why? Please note that it’s entirely possible the best way is something I have not considered.

unor
  • 92,415
  • 26
  • 211
  • 360
ACJ
  • 2,499
  • 3
  • 24
  • 27

1 Answers1

1

The glossary link type refers to "a document providing a glossary of terms that pertain to the current document".

The bookmark link type gives the permalink for the nearest ancestor article, and if there is none, for the nearest ancestor section.

So, when you link to a term definition for a term that appears in a blog post (or similar), you must not use the bookmark type, otherwise the permalink for this blog post would be the URL of the term definition. But as the blog post contains terms that are defined in the glossary, you can link to the glossary with the glossary link type.

<!DOCTYPE html>
<title>Blog post that contains a term defined in the glossary</title>
<link rel="glossary" href="/glossary" />

<article>
  <p>The <a href="/glossary#foo">foo</a> is great.</p>
</article>

Providing fragment identifiers for the glossary should never hurt, and it would even be required in a few cases: for example, when the fragment identifier is needed to display the glossary, or when the document contains other main content in addition to the glossary.


NB: You could use the dfn element in the dt element, and move the id attribute to the dfn element.

<dl id="dictionary">
  <dt><dfn id="foo">foo</dfn></dt>
  <dd>A foo is not a <a href="#bar">bar</a>.</dd>
</dl>

You might also be interested in adding structured data, using Schema.org’s DefinedTerm and DefinedTermSet.

unor
  • 92,415
  • 26
  • 211
  • 360
  • Thanks! You’re right, the newer specifications pretty much provide the answers. (I think the `bookmark` relation is older than the `article` and `section` elements, but now that they’re defined the way they are, it leaves little room for interpretation.) I guess I was hoping to add some semantic attribute to links that point to specific terms, so I can style those accordingly. Another mechanism will have to do (maybe just a `class`). Lastly, I think a `dfn` inside a `dt` is redundant, but I will definitely apply the microdata. Thanks again! – ACJ May 15 '19 at 07:30
  • 1
    @ACJ: I would say `dfn` inside `dt` is not redundant, because `dl` is no longer a *definition* list, but a *description* list (that can take any kind of name-value pairs). By using `dfn`, you convey that it’s a term and its definition. – unor May 15 '19 at 08:19
  • Ah, right. Sometimes my mind jumps back to old definitions. Thanks again! – ACJ May 15 '19 at 09:44