User:Timeshifter/Sandbox196
Please do not edit this sandbox. Please use your own sandbox.
Edited excerpts from Template:Anchor/doc
__TOC__
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 class="anchor" id="Basic format. Test"></span>
{{anchor|Under-Foo}}
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:
which will be saved in the article as:
== Section header{{code|1={{Anchor|Anchor name}}}} ==
Anchor names are case sensitive, so
and
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<span class="anchor" id="Rationale for placement above header"></span><span class="anchor" id="substitution_reason_anchor"></span>
To show why substitution in the header is preferred, the following anchor is placed in the Basic format section header:
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 ==
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.
== 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
The link (and anchor link) #Basic format still works.
And here is the page source within that H2 tag:
Basic format[edit | edit source]
Same additional anchor added. Current header name
The link (and anchor link) #Basic format still works. All the anchor links still work:
And here is the page source within that H2 tag:
Basic format[edit | edit source]
When header changed to "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:
And here is the page source within that H2 tag:
Basic format. Test
The last anchor was added by Mediawiki after I had added and removed "Test" a couple times from the heading.