Template:Anchor

From Cassette Beasts
Revision as of 16:45, 8 December 2024 by Mezzodrinker (talk | contribs) (Created page with "<onlyinclude>{{#tag:span|{{{2|}}}|class=anchor|id={{anchorencode:{{{1}}}}}}}</onlyinclude> The '''{{PAGENAME}}''' template creates a new anchor that can be used for linking t...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The Anchor template creates a new anchor that can be used for linking to sections or specific regions of a page.

Parameters

1
Name of the anchor. Will be encoded into an anchor string using the {{anchorencode:}} magic word.
2
(optional)
The text with which the anchor should be created. Leave this blank to make the anchor invisible.

Usage

(See the MediaWiki help on link anchors for details)

When used, this template produces a <span> element that has the specified anchor name. For example, the template call {{Anchor|My custom anchor}} produces the following output:

<span class="anchor" id="My_custom_anchor"></span>

This anchor can then be linked to using the link [[#My_custom_anchor|Link to my custom anchor]]. Note that the link destination uses the anchor-encoded anchor name. To make this conversion easier and less error-prone, you can also use Template:AnchorLink.