Jump to content

User:Timeshifter/Sandbox196

From Wikipedia, the free encyclopedia

Please do not edit this sandbox. Please use your own sandbox.

Edited excerpts from Template:Anchor/doc

Basic format

[edit]

You can define one or more anchor names, separated by |. This can be useful for alternative spellings, such as "humor" and "humour."

In general, an anchor is placed at the end of a section header by substitution:
== Section header{{subst:anchor|Anchor name}} ==

which will be saved in the article as:
== Section header<span class="anchor" id="Anchor name"></span> ==

Anchor names are case sensitive, so [[#Anchor name]] and [[#Anchor Name]] are not equivalent. When making an anchor, in general capitalize the first letter of the anchor name, and follow the same capitalization guidelines as headers (see Manual of Style: Headers for more information).

Rationale for substitution in the header

[edit]

To show why substitution in the header is preferred, the following anchor is placed in the Basic format section header:
== Basic format<span class="anchor" id="Foo"></span><span class="anchor" id="In-Foo"></span> ==

Since the anchor is actually used on this documentation page, the links #Basic format, #Foo and #In-Foo all work and can be tested to see the effect.

For contrast, an anchor named #Under-Foo has also been placed underneath the Basic format section header and can be clicked to illustrate how this placement hides the section title when jumping to the linked target:
== Basic format ==
{{anchor|Under-Foo}}

Another anchor named #Above-Foo has been placed above the section header. This anchor does work correctly, but because the anchor is technically not in the section but before it, it makes editing counter-intuitive.
{{anchor|Above-Foo}}
== Basic format ==

Anchors should also never be left unsubstituted within a section header, as this violates MOS:HEADINGS and causes technical complications.

Additional anchor added. Current header name

[edit]

== Basic format {{subst:anchor|Basic format}} ==

The link (and anchor link) #Basic format still works.

And here is the page source within that H2 tag:

<h2><span class="mw-headline" id="Basic_format">Basic format<span class="anchor" id="Foo"></span><span class="anchor" id="In-Foo"></span><span class="anchor" id="Anchor_name_1"></span><span class="anchor" id="Anchor_name_2"></span><span class="anchor" id="Basic_format"></span></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=User:Timeshifter/Sandbox196&veaction=edit&section=1" class="mw-editsection-visualeditor" title="Edit section: Basic format">edit</a><span class="mw-editsection-divider"> | </span><a href="/w/index.php?title=User:Timeshifter/Sandbox196&action=edit&section=1" title="Edit section: Basic format">edit source</a><span class="mw-editsection-bracket">]</span></span></h2>
<span class="mw-headline" id="Basic_format">
<span class="anchor" id="Foo">
<span class="anchor" id="In-Foo">
<span class="anchor" id="Anchor_name_1">
<span class="anchor" id="Anchor_name_2">
<span class="anchor" id="Basic_format">

Same additional anchor added. Current header name

[edit]

== Basic format {{subst:anchor|Basic format}} ==

The link (and anchor link) #Basic format still works. All the anchor links still work:

#Foo

#In-Foo

#Anchor_name_1

#Anchor_name_2

And here is the page source within that H2 tag:

<h2><span class="mw-headline" id="Basic_format">Basic format<span class="anchor" id="Foo"></span><span class="anchor" id="In-Foo"></span><span class="anchor" id="Anchor_name_1"></span><span class="anchor" id="Anchor_name_2"></span><span class="anchor" id="Basic_format"></span><span class="anchor" id="Basic_format"></span></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=User:Timeshifter/Sandbox196&veaction=edit&section=1" class="mw-editsection-visualeditor" title="Edit section: Basic format">edit</a><span class="mw-editsection-divider"> | </span><a href="/w/index.php?title=User:Timeshifter/Sandbox196&action=edit&section=1" title="Edit section: Basic format">edit source</a><span class="mw-editsection-bracket">]</span></span></h2>
<span class="mw-headline" id="Basic_format">
<span class="anchor" id="Foo">
<span class="anchor" id="In-Foo">
<span class="anchor" id="Anchor_name_1">
<span class="anchor" id="Anchor_name_2">
<span class="anchor" id="Basic_format">
<span class="anchor" id="Basic_format">

When header changed to "Basic format. Test"

[edit]

== Basic format {{subst:anchor|Basic format. Test}} ==

See old version:
https://en.wikipedia.org/w/index.php?title=User:Timeshifter/Sandbox196&oldid=1157602043

This page version was after I had added and removed "Test" a couple times from the "Basic format" heading.

When on that old version with the heading named "Basic format. Test" you will see that the anchor link #Basic format still works. All the anchor links still work on that old version, as does the new anchor:

#Basic format. Test

#Foo

#In-Foo

#Anchor_name_1

#Anchor_name_2

And here is the page source within that H2 tag:

<h2><span class="mw-headline" id="Basic_format._Test">Basic format. Test<span class="anchor" id="Foo"></span><span class="anchor" id="In-Foo"></span><span class="anchor" id="Anchor_name_1"></span><span class="anchor" id="Anchor_name_2"></span><span class="anchor" id="Basic_format"></span><span class="anchor" id="Basic_format"></span><span class="anchor" id="Basic_format._Test"></span></span></h2>
<span class="mw-headline" id="Basic_format._Test">
<span class="anchor" id="Foo">
<span class="anchor" id="In-Foo">
<span class="anchor" id="Anchor_name_1">
<span class="anchor" id="Anchor_name_2">
<span class="anchor" id="Basic_format">
<span class="anchor" id="Basic_format">
<span class="anchor" id="Basic_format._Test">

The last anchor was added by Mediawiki after I had added and removed "Test" a couple times from the heading.