Template:Anchor/doc: Difference between revisions

From Portals of Phereon Wiki
Content added Content deleted
m (1 revision imported)
m (3 revisions imported)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
This template manually adds one or more HTML anchors (i.e., link targets) to a page. This allows incoming links to target locations on the page other than section headings.
{{doc/start}}
Anchors are "jump points". Place them somewhere on a page and you will be able to link to that section of the page directly. Without the use of ==sections/headings/titles==.


{{t|anchor|target}}
==Usage==
{{t|anchor|target|Target|TARGET}}
<nowiki>{{</nowiki>Anchor|''Anchor ID''}}


This allows links of the form <code><nowiki>[[#target]]</nowiki></code> to be used on the same page and links of the form <code><nowiki>[[Page title#target]]</nowiki></code> to be used on a different page (assuming "Page title" is the title of the page this template is used on).
*''Anchor ID'' is the text after the # character that you would like to be used in a link.
*These anchors are invisible.


The second example usage shows how multiple anchors can be provided within a single template call. It also illustrates how capitalization differences are significant in HTML anchor names; for this reason, if you suspect that incoming links will try to use targets with different capitalization (or punctuation, whitespace, etc.), then all allowed forms must be explicitly listed in the template call.
==How to link to anchors==

As an example, if you placed <nowiki>{{</nowiki>Anchor|Foo}} on the [[Sandbox]] page, you could use <nowiki>[[</nowiki>Sandbox#Foo]] as a link that jumps to it.
Up to 10 targets can be specified in a single template call, otherwise an error message will be displayed (this message may break the page layout) and the current page will be listed in the error-tracking <span class="plainlinks">[{{fullurl:Category:Template errors}} Category:Template errors]</span> (this maintenance category should remain empty and does not need to be created). If more anchors are are needed, a second template call can immediately follow the first one.
{{doc/end}}
<includeonly>[[Category:Templates|{{PAGENAME}}]]</includeonly><noinclude>[[Category:Template documentation|{{PAGENAME}}]]</noinclude>

Latest revision as of 18:52, 12 December 2020

This template manually adds one or more HTML anchors (i.e., link targets) to a page. This allows incoming links to target locations on the page other than section headings.

{{anchor|target}}
{{anchor|target|Target|TARGET}}

This allows links of the form [[#target]] to be used on the same page and links of the form [[Page title#target]] to be used on a different page (assuming "Page title" is the title of the page this template is used on).

The second example usage shows how multiple anchors can be provided within a single template call. It also illustrates how capitalization differences are significant in HTML anchor names; for this reason, if you suspect that incoming links will try to use targets with different capitalization (or punctuation, whitespace, etc.), then all allowed forms must be explicitly listed in the template call.

Up to 10 targets can be specified in a single template call, otherwise an error message will be displayed (this message may break the page layout) and the current page will be listed in the error-tracking Category:Template errors (this maintenance category should remain empty and does not need to be created). If more anchors are are needed, a second template call can immediately follow the first one.