Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Help:Section
(section)
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!
== Section linking == {{See also|Help:Link#Section linking (anchors)|Wikipedia:Manual of Style/Linking#Section links}} In the HTML code for each section there is an "id" attribute holding the section title. This enables [[w:hyperlink|linking]] directly to sections. These section anchors are automatically used by MediaWiki when it generates a table of contents for the page, and therefore when a section heading in the ToC is clicked, it will jump to the section. Also, the section anchors can be manually linked directly to one section within a page. The HTML code generated at the beginning of this section, for example, is: <syntaxhighlight lang="html"> <span class="mw-headline" id="Section_linking">Section linking</span> </syntaxhighlight> A link to this section ([[Help:Section#Section linking|Section linking]]) looks like this: :{{code|[[Help:Section#Section linking|Section linking]]}} (NB section links are case sensitive, including the first character ([[Help:Link#Section linking (anchors)|Help:Link]]).) To link to a section in the same page you can use {{code|[[#section name|displayed text]]}}, and to link to a section in another page {{code|[[page name#section name|displayed text]]}}. The anchors disregard the depth of the section; a link to a subsection or sub-subsection etc. will be {{code|[[#subsection name]]}} and {{code|[[#sub-subsection name]]}} etc. An underscore and number are appended to duplicate section names. E.g. for three sections named "Example", the names (for section linking) will be "Example", "Example_2" and "Example_3". However, after editing section "Example_2" or "Example_3" (see below), one, confusingly, arrives at section "Example" from the [[Help:edit summary|edit summary]]. If a section has a blank space as heading, it results in a link in the TOC that does not work. For a similar effect see [[Help:Parser function#NS:0|NS:0]]. To create an anchor target without a section heading, you can use the {{tl|anchor}} template or a span: {{tag|span|params=id="anchor_name"|content=}}. To format a link to a section with a [[section sign]] ("Β§") rather than with "#" or custom text, use {{tl|Section link}} (or {{tl|slink}}). For example, {{tlx|Section link|Foo|Bar}} is equivalent to a [[Foo#Bar]] link, but is formatted {{Section link|Foo|Bar}}. '''Notes:''' * An internal link in a section heading does not cause complications to section linking; however, editors who have their preferences set to edit sections by clicking on the header will not be able to click these links: ** [[#Demo a]] ** [[Help:Section#Demo http://a]] ** http://meta.wikimedia.org/wiki/Help:Section#Demo_http:.2F.2Fa * The [[Help:Pipe_trick|pipe trick]] does not work for section links: ** {{code|[[#section| ]]}} → [[#section| ]] ** {{code|[[page#section| ]]}} → [[page#section| ]] ** {{code|[[namespace:page#section| ]]}} → [[namespace:page#section| ]] For linking to an arbitrary position in a page see [[Wikipedia:Section linking|Section linking (anchors)]]. === Section linking and redirects === A link that specifies a section of a redirect page corresponds to a link to that section of the target of the redirect. A [[Help:redirect|redirect]] to a section of a page will also work, try e.g. the redirect page [[Help:Section linking and redirects|Section linking and redirects]]. A complication is that, unlike renaming a page, renaming a section does not create any redirect from the old section name. Therefore, incoming links to the old section name will have to be fixed. This problem can be fixed by adding a manual anchor link to the old name, using the [[Template:Anchor|Anchor]] template. However, if you do not want to retain links to the old names, you will need to track them down and fix them. There is no separate [[Help:What links here|What links here]] feature for sections: the list does not distinguish between links to one section or another and links to the entire page. The following possible workarounds will help "future proof" incoming links you make to a section, but they will not help with tracking down simple links to sections during a rename: * Instead of linking directly to a section, link to a page that redirects to the section; when the name of the section is changed, just change the redirect target. With this method, pages linking to the section can be identified by using ''What links here'' on the redirect page. * Use a manual anchor when you wish to link to a section, so that you do not have to rely on the section name being stable. * Put a [[MOS:COMMENT|comment]] in the wikitext at the start of a section listing pages that link to the section. * Make the section a separate page/template and either transclude it into, or just link to it from, its parent page; instead of linking to the section one can then link to the separate page. Redirect pages can be categorized by adding a category tag after the redirect command. In the case that the target of the redirect is a section, this has, to some extent, the effect of categorizing the section: through the redirect, the category page links to the section; however, unless an explicit link is present, the section does not link to the category. On the category page, redirects are displayed with class redirect-in-category, so they can be shown in e.g. italics; this can be defined in [[MediaWiki:Common.css]]. See also [[WP:Categorizing redirects]].
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)