Template:Anchor/doc
{{Anchor}} inserts one or more HTML anchors in an article at the location of its invocation, enabling direct links to the {{Anchor}} location within an article.
Usage
{{Anchor|(anchor name)}}
You must provide at least one anchor name.
- (anchor name)
- The name you wish to use to refer to this location.
Linking
You can link directly to the line you anchored. For example, if an anchor on an article is:
{{Anchor|Habitat and ecology}}
you can link to that location using a hash sign in a standard wiki link:
[[#Habitat and ecology|habitats]]
Clicking that link scrolls the current article to the Habitat and ecology section.
If the anchor is on a different article, add the hash sign and anchor name directly after the article name:
[[Thriae#Habitat and ecology|habitats]]
Clicking that link opens the Thriae article and scrolls to its Habitat and ecology section.
If you want, you can add multiple anchor names to a single anchor:
{{Anchor|Habitat|Ecology}}
You can then link to the same location using either [[#Habitat]]
or [[#Ecology]]
.
Note that headings are automatically anchored, and you can link to them using the same syntax. For example, you can also link to the heading:
== Habitat and ecology ==
with:
[[#Habitat and ecology|habitats]]
When used to add anchors to a paragraph of prose, put the template at the very start of the paragraph (stuck to the first word, without space) to ensure that incoming anchor links result in the full paragraph being displayed on the reader's screen.
To add anchors to a heading, {{Anchor}} must be placed inside the heading tag itself:
== Habitat and ecology {{Anchor|Habitats|Ecology}} ==
Anchor names
Due to technical limitations, anchor names can not include characters "#" (hash), "|" (pipe) or "=" (equal). On the other hand, other special characters such as " " (space), "," (comma), "&" (ampersand), etc. can be used directly both in anchors and links because the software will process them automatically.
Anchor names should preferably be written in "Sentence case" (as is the standard for headings and thus their anchors); that is, capitalize the first letter of the first word and any proper nouns, but leave the rest lowercase. Examples: "The title of my anchor", "The anchor from Ipanema", etc. Because some browsers have case-sensitive anchors, the anchor name used in a #Link should be absolutely identical to its target (rather than all-lowercase).
Anchor names should be unique with respect to all heading titles and additional anchors on the article. A duplicate anchor won't work since the links will always go to the first homonymous anchor on the article.