Changes

Jump to: navigation, search

User:Lakrits/sandbox

6,467 bytes added, 18:18, 6 January 2015
-
{{User sandbox}}
<!-- Edit below this line DO NOT REMOVE this comment or the content above! -->
__NOTOC__
==Usage==
{{tlf|'''anchor'''}} inserts one or more HTML fragment identifiers, commonly known as ''anchor names'', at the location where you put the template in a page. It does so by using the {{samp|id}} attribute within {{tag|span|o}} tags:
:{{code|<nowiki><span id="Anchor name"></span></nowiki>}}
These locations can then be linked to using the in-page wikilink syntax {{code|<nowiki>[[#Anchor name|…]]</nowiki>}}.
 
==Parameters==
There are 10 parameters, all unnamed, of which 1 is required and the remaining 9 are optional.
 
===Syntax===
The template's syntax is
* {{tlc|anchor|anchor1&nbsp;|anchor2&nbsp;|anchor3&nbsp;|…|anchor10&nbsp;}}
 
;<big>Example anchors</big>
Anchors are "invisible" on the page, i.e. they're can only be seen as code inside the source code. You can click the links below to see how anchors work. They will take you to the ''Examples'' section, and the corresponding example anchor.
* [[#Example1|Link 1]] goes to a location ("Target 1") with only 1 anchor name attached to it.
* [[#Example2|Link 2]], [[#Example3|link 3]], and [[#Example4|link 4]] go to a location ("Target 2") with 3 anchor names attached to it.
* [[#Example5|Link 5]] goes to a mock section title ("Section title A" in the ''Examples'' table), which has been given an anchor using {{tlf|anchor}}.
* [[#Example6|Link 6]] goes to a mock section title ("Section title B" in the ''Examples'' table), which has been given an anchor using HTML code.
 
===Required parameter===
====1====
;<big>Anchor name</big>
The name of the (first) anchor.
 
;<big>Notes</big>
* There are some limitations to anchor names, e.g. concerning usage and syntax. See the section [[#Limitations|Limitations]], below.
 
;<big>Usage</big>
* {{tlc|anchor|<big>'''1'''</big>}}
 
===Optional parameters===
====2–10====
;<big>Additional anchor names</big>
If you want, you can specify up to nine additional anchor names in the template (i.e. a maximum number of 10 anchor names).
 
;<big>Notes</big>
* There are some limitations to anchor names, e.g. concerning usage and syntax. See the section [[#Limitations|Limitations]], below.
* If 11 or more anchor names are specified, the template will show an error message.
 
;<big>Usage</big>
* {{tlc|anchor|1|<big>'''2'''</big>|<big>'''3'''</big>|…|<big>'''10'''</big>}}
 
===Limitations===
{| class="wikitable" style="float: right; background-color: white;"
! Character
! Code
! Template
! Meaning
|-
| &quot;
| {{code|&amp;quot;}} <br>{{code|&amp;#34;}}
| {{N/A}}
| Quotation mark
|-
| &#35;
| {{code|&amp;#35;}}
| {{N/A}}
| Number sign
|-
| &#124;
| {{code|&amp;#124;}}
| {{tn|!}}
| Vertical bar
|-
| &#61;
| {{code|&amp;#61;}}
| {{tn|{{=}}}}
| Equals sign
|}
;<big>Troublesome characters</big>
* Anchor names that contain any character shown in the table to the right will not work as expected. However, any of these characters can be replaced with the "&amp;#…" codes shown for them here. The pipe symbol and equals sign can optionally be worked around with {{tn|!}} and {{tn|{{=}}}}, respectively. Most other characters, including white space and punctuation, are not a problem.
 
;<big>Markup code</big>
* Markup code such as {{tag|sup|o}} and {{tag|sub|o}} (superscript and subscript) cannot be used.
 
;<big>Duplicate anchor names</big>
* All wiki article and section titles created by using wiki markup ({{code|<nowiki>==, ===, etc.</nowiki>}}) automatically produce anchors with the same name as the titles themselfs. Duplicate anchors will not work as expected since the {{code|<nowiki>#location</nowiki>}} links go to the first anchor with that name. Because of this, anchor names should be unique on a page. Make sure your anchors don't duplicate any titles or other anchors, including ones written in direct HTML.
 
;<big>Section titles</big>
* If the template is added to a section title then the code will appear in the edit summary window when that section is edited, as in "{{code|<nowiki>/*&nbsp;{{anchor|Issues}}Limitations&nbsp;*/&nbsp;New&nbsp;issue</nowiki>}}". Also, when the section is saved, browsers may not return to the section. Consider using {{code|<nowiki><span id="…"></span></nowiki>}} directly, rather than using the anchor template, when in a section title.
 
;<big>Treat as case-sensitive</big>
* Anchor links are case-sensitive in some browsers, so treat all anchor links as case-sensitive.
 
==Examples==
The links to the targets in the table can be found under [[#Syntax|''Syntax'']] > ''Example anchors'', above.
{| class="wikitable" style="background-color: white;"
! Case
! What you write
! What you see
! Comments
|-
| Basic use
| {{tlc|anchor|Example1}} {{code|Target 1}}
| {{anchor|Example1}} Target 1
| Can be linked to with {{code|<nowiki>[[#Example1|…]]</nowiki>}} from within the same article, or with {{code|<nowiki>[[Article name#Example1|…]]</nowiki>}} from other articles and from redirects.
|-
| Multiple anchors
| {{tlc|anchor|Example2|Example3|Example4}} {{code|Target 2}}
| {{anchor|Example2|Example3|Example4}} Target 2
| Creates three anchors for the same target location that then can be linked to with {{code|<nowiki>[[#Example2|…]]</nowiki>}}, {{code|<nowiki>[[#Example3|…]]</nowiki>}}, or {{code|<nowiki>[[#Example4|…]]</nowiki>}}, respectively.
|-
| Section title <br>(template)
| {{code|<nowiki>==</nowiki>&nbsp;}}{{tlc|anchor|Example5}}{{code|&nbsp;Section title A&nbsp;<nowiki>==</nowiki>}}
| {{anchor|Example5}}&nbsp;<span style="font: 21px Fira Sans; text-decoration: underline;">Section title A</span>
| Anchors can be more suitable for inter-article linking than section titles are. In this case, links in the format {{code|<nowiki>[[Article name#Example5]]</nowiki>}} would remain valid even if the section itself was renamed. (Note that the anchor is placed ''before'' the section name; otherwise browsers may hide the section title from view.)
|-
| Section title <br>(HTML)
| {{code|<nowiki>==</nowiki>&nbsp;<nowiki><span id="Example6"></span></nowiki>&nbsp;Section title B&nbsp;<nowiki>==</nowiki>}}
| {{anchor|Custom anchor name}}&nbsp;<span id="Example6"></span><span style="font: 21px Fira Sans; text-decoration: underline;">Section title B</span>
| As noted under [[#Limitations|Limitations]] above, it may be preferable to use direct HTML rather than the template within section titles.
|}
 
==External links==
* [[Wikipedia:HTML attribute|''HTML attribute'']] on English Wikipedia.
* [[Wikipedia:Span and div|''Span and div'']] on English Wikipedia.
 
<!-- Categories for this sandbox. DO NOT REMOVE! -->
[[Category:User sandboxes]]
3,860
edits

Navigation menu