Anonymous
Not logged in
Talk
Contributions
Create account
Log in
Guild of Archivists
Search
Editing
Template:Anchor/doc
(section)
From Guild of Archivists
Namespaces
Template
Discussion
More
More
Page actions
Read
Edit source
History
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Examples == # <code style="color:darkgreen;"><nowiki>{{</nowiki>{{lc:{{BASEPAGENAME}}}}|Foo<nowiki>}}</nowiki></code> <br> could be linked to with <code><nowiki>[[#Foo|...]]</nowiki></code> from within the same article, <br> or it could be linked to with {{nowrap|<code><nowiki>[[</nowiki>''<small>Article name</small>''#Foo<nowiki>|...]]</nowiki></code>}} from other articles and from redirects. # Anchors can be more suitable for inter-article linking than section titles are. For example: <br> {{nowrap|1=<code style="color:dimgray;"><nowiki>==</nowiki><span>{{sp}}</span><code style="color:darkgreen;"><nowiki>{{</nowiki>{{lc:{{BASEPAGENAME}}}}<nowiki>|Foo}}</nowiki></code><span>{{sp}}</span>Section title <nowiki>==</nowiki></code>}} <br> Here, links via {{nowrap|1=<code><nowiki>[[</nowiki>''Article name''#Foo<nowiki>]]</nowiki></code>}} would remain valid even if the section were renamed. (Note that the anchor is placed ''before'' the section name; otherwise browsers may hide the section title from view.) However, as noted under [[#Limitations|Limitations]] below, it may be preferable to use direct HTML rather than the template within section titles: <br> {{nowrap|1=<code style="color:dimgray;"><nowiki>==</nowiki><span>{{sp}}</span><code style="color:darkgreen;"><nowiki><span id="Foo"></span></nowiki></code><span>{{sp}}</span>Section title <nowiki>==</nowiki></code>}} # The template can be used to create multiple anchors with a single call. For example, <br> {{nowrap|1=<code style="color:darkgreen;"><nowiki>{{</nowiki>{{lc:{{BASEPAGENAME}}}}<nowiki>|Foo|Bar|baz}}</nowiki></code>}} <br> will create three anchors that can then be linked to with <code><nowiki>[[#Foo]]</nowiki></code>, <code><nowiki>[[#Bar]]</nowiki></code> and <code><nowiki>[[#baz]]</nowiki></code>. === Limitations === {|class="wikitable" style="float:right" !Character !Code !Template !Meaning |- |" |<code>&quot;</code> <br /><code>&#34;</code> |{{N/a}} |(double) quotation mark |- |# |<code>&#35;</code> |{{N/a}} |hash |- || |<code>&#124;</code> |{{tl|!}} |pipe |- |= |<code>&#61;</code> |{{tl|{{=}}}} |equals |} * Anchor names that contain any character shown in the table on the right will not work as expected. However, any of these characters can be replaced with the "&#" codes shown for them here. Or, the pipe symbol and equals sign can be worked around with {{tl|!}} and {{tl|{{=}}}}, respectively. Markup code such as {{tag|sup|o}} and {{tag|sub|o}} (superscript and subscript) cannot be used. Most other characters, including white space and punctuation, are not a problem. * Anchor names should be unique on a page, and should not duplicate any heading titles. Duplicate anchors will not work as expected since the <code><nowiki>#location</nowiki></code> links go to the first anchor with that name. Duplicate anchors result in invalid HTML; you can check for duplicate anchors by running the page through the [[w:W3C Markup Validation Service]]. * 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 {{nowrap|1="<code><nowiki>/* {{anchor|Issues}}Limitations */ New issue</nowiki></code>"}}. Also, when the section is saved, browsers may not return to the section. Consider using <code><nowiki><span id="..."></span></nowiki></code> directly, rather than using the anchor template, when in a section title. * Anchor links are case sensitive in some browsers, so treat all anchor links as case sensitive. === Use in tables === Anchors may be used within tables, subject to certain restrictions. The {{tlx|anchor}} template may be used in the caption and cells of a table, but not those portions of a table that are outside the caption and cells. It is used on the table's caption thus:<source enclose=div lang=text>|+ {{anchor|FooX}} A table caption</source> and the following forms of cell are valid:<source enclose=div lang=text>!{{anchor|Foo1}} A header cell !style="background:white;" |{{anchor|Foo2}} A header cell with styling |{{anchor|Foo3}} A data cell |rowspan=2 |{{anchor|Foo4}} A data cell spanning two rows</source> You need to ensure that the {{tlx|anchor}} is not in that portion of the markup intended for the classes, styles etc. Thus, {{tlx|anchor}} cannot be placed anywhere on lines that begin with <code><nowiki>{|</nowiki></code> (start of table) or <code><nowiki>|-</nowiki></code> (new row), and the following forms of cell are not valid:<source enclose=div lang=text>!{{anchor|Foo1}} |A header cell !style="background:white;" {{anchor|Foo2}} |A header cell with styling |{{anchor|Foo3}} |A data cell |rowspan=2 {{anchor|Foo4}} |A data cell spanning two rows</source> If it is necessary for an anchor to be in any of these positions, a different technique is used - the <code>id=</code> attribute. This is placed in that portion of the markup where the classes, styles etc. may be used, as follows:<source enclose=div lang=text>{| id=FooX class=wikitable |- id=FooY !id=Foo1 |A header cell !style="background:white;" id=Foo2 |A header cell with styling |id=Foo3 |A data cell |rowspan=2 id=Foo4 |A data cell spanning two rows</source> The <code>id=</code> attribute may appear before, between or after any other attributes that may be present, but only one <code>id=</code> attribute may be used in each of these areas. === TemplateData === {{TemplateDataHeader}} <templatedata>{ "description": "The template {{anchor}} inserts one or more HTML anchors in a page. Those locations can then be linked to using [[#location|...]] syntax. The parameters here are for convenience; no parameter name is required in the template itself.", "params": { "1": { "label": "First anchor", "description": "First anchor; Only the first anchor is required.", "type": "string", "required": true }, "2": { "label": "Second anchor", "description": "Second anchor.", "type": "string", "required": false }, "3": { "label": "Third anchor", "description": "Third anchor. For additional anchors, just type in 4 as the parameter name for the next, 5 for the next after that, and so on.", "type": "string", "required": false } }}</templatedata> === See also === * {{tl|Shortcut}} <includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox|| <!-- CATEGORIES HERE, AND INTERWIKIS TO WIKIDATA, THANKS --> [[Category:Wikipedia formatting and function templates]] }}</includeonly>
Summary:
Please note that all contributions to Guild of Archivists may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
GoArch:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation
Navigation
Main Page
Random page
Categories
All pages
Recent changes
Resources
D'ni dictionary
Reference material
Utilities
Community
Forums
Jalak Game Directory
Projects
Apocrypha
Unexplored Branches
All projects
Contribute
Stubs
Wanted
Cleanup
Dead ends
Image requested
Help
Help
Guide
Policies
Wiki tools
Wiki tools
Special pages
Page values
Page tools
Page tools
User page tools
More
What links here
Related changes
Page information
Page logs