Defining custom anchor links
id
attribute.less than a minute
For modern browsers and contexts, use the HTML id
attribute to define a custom anchor target (also called a fragment identifier).
Some tools, such as online services or wikis, don’t provide convenient ways to set IDs in documents.
If you’re working with such a tool and it supports HTML, trying using the HTML anchor element (<a>
) to define the anchor target.
<a name="myanchor"></a>
While deprecated in HTML5, many browsers still support this markup. As a result, it’s an effective workaround for limited use.
Be sure to investigate your tool carefully before using this, as there might be more appropriate alternatives.
For example, some static site generators (SSGs) support alternate approaches:
Here's a thing to link to...
{id="myanchor"}
This example shows an optional behavior supported by Hugo: an inline declaration specified on the line immediately following the target location. Support depends on the tool and how it’s configured for a specific site.
Vital statistics
- 18 August 2025: First post for this site