Help:Section

A page can and should be divided into sections, using the section heading syntax. For each page with more than three section headings, a table of contents (TOC) is automatically generated. This page explains the syntax of these elements. For information about how to name sections or how to use sections to structure articles, please read the Wikipedia:Guide to layout.

Please do not use only one equals sign on a side (=Heading=). This would cause a section heading to be as large as the page's name (title). The maximum number of equals signs is six.

Heading names of sections (including subsections) should be unique on a page. Using the same heading more than once on a page causes problems:

For registered users who use Preferences → Appearance → Auto-number headings, sections are numbered both in the table of contents and at beginning of each section heading. Otherwise, they are numbered only in the table of contents.

For each page with at least four headings, a table of contents (TOC) is automatically generated from the section headings unless the magic word __NOTOC__ (with two underscores on either side of the word) is added to the article's wikitext. __NOTOC__ should not be used in articles that (a) have fewer than four headings or (b) do not fit on one screen.[1]

When either __FORCETOC__ or __TOC__ (with two underscores on either side of the word) is placed in the wikitext, a TOC is generated even if the page has fewer than four headings.

Using __FORCETOC__ places the TOC immediately before the first section heading. Using __TOC__ places the TOC at the same position as this code.

Most articles have introductory text before the TOC, known as the "lead section". Although usually a section heading should immediately follow the TOC, using __TOC__ can prevent you from being forced to insert a meaningless heading just to position the TOC correctly (i.e. not too low). However, if there is any text at all between the TOC and the first heading, this will cause problems with accessibility.

Template:TOC right was proposed for deletion in early July 2005, but there was no consensus on the matter. The archive of the discussion and voting regarding this may be seen at Wikipedia:Templates for deletion/TOCright. The Manual of Style discussion can be found here.

The TOC is automatically generated with HTML id="toc". You can make a link to it with [[#toc]]:

Example: Legality of cannabis by country – uses a concise but functional A–Z horizontal TOC.
Example: – uses two TOCs; a short, vertical one, and a long, horizontal one.

In the HTML code for each section there is an "id" attribute holding the section title. This enables 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:

(NB section links are case sensitive, including the first character (Help:Link).)

To link to a section in the same page you can use [[#section name|displayed text]], and to link to a section in another page [[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 [[#subsection name]] and [[#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 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 NS:0.

For linking to an arbitrary position in a page see Section linking (anchors).

A link that specifies a section of a redirect page corresponds to a link to that section of the target of the redirect.

A redirect to a section of a page will also work, try e.g. the redirect page 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 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 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:

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 put, 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.

Sections can be separately edited by clicking special edit links labeled "[edit]" by the heading or by right clicking on the section heading. This is called "section editing".

The section editing feature will take you to an edit page by a URL such as

Note that here section numbers are used, not section titles; subsections have a single number, e.g., section 2.1 may be numbered 3, section 3 is then numbered 4, etc. You can also directly type in such URLs in the address bar of your browser.

This is convenient if the edit does not involve other sections and one needs not have the text of other sections at hand during the edit. (But if one does need the article during a section edit, you could open the section "edit" link in a new window, or during section editing, open the article or page in a different window). Section editing alleviates some problems of large pages by making it slightly faster and much easier to find the text that you want to change.[2] It also may help when the full page is just too large for the browser to handle all-at-once in the editor.

Adding the code __NOEDITSECTION__ anywhere on the page will remove the edit links. It will not disable section editing itself; the URL can still be accessed manually.

Inserting a section can be done by editing either the section before or after it. An editor can merge one section with the previous section by deleting the heading. Note that in these cases the preloaded section name in the edit summary is not correct, and has to be changed or deleted.

Navigation on pages from "talk" namespaces provides a special link labeled "New section", "+", or "Add topic" used to create a new section to the end of the page.[3] Pages having the code __NEWSECTIONLINK__ in wikitext also display this link, regardless of the namespace.

In this case, a text box having as title "Subject/headline", will appear and the content you type in it will become the name of the new section heading. There is no input box for the edit summary; it is automatically created. Do not edit the last existing section to create a new one, because it will result in a misleading edit summary which will conceal creation of the section and may confuse other users.

By default, there is no link to edit the lead section of a page, so the entire page must be edited. Lead section editing can be enabled through .

Preferences → Gadgets → Appearance → Add an [edit] link for the lead section of a page

The preview in section editing does not always show the same as the corresponding part of the full page, e.g. if on the full page an image in the previous section intrudes into the section concerned. Also, <ref>s usually become hidden; see #Editing a footnote for a solution.

The edit page shows the list of templates used on the whole page, i.e. also the templates used in other sections.

Subsections are included in the part of the section that is edited. Section numbering is relative to the part that is edited, so on the relative top level there is always just number 1, relative subsections all have numbers starting with 1: 1.1., 1.2, etc.; e.g., when editing subsection 3.2, sub-subsection 3.2.4 is numbered 1.4. However, the heading format is according to the absolute level.

To edit a footnote rendered in a section containing the code <references />, edit the section with the footnote mark referring to it (see Help:Footnotes). Previewing the section will show a preview of the footnote.

If a page has very large sections, or is very large and has no division into sections, and one's browser or connection does not allow editing of such a large section, then one can still:

If one can view the wikitext of a large section, one can divide the page into smaller sections by step by step appending one, and finally deleting the original content (this can be done one large section at a time). Thus temporarily there is partial duplication of the content, so it is useful to put an explanation in the edit summary.

When conditionally (using a parser function) transcluding a template with sections, the "edit" links of this and subsequent sections will edit the wrong section or give the error message that the section does not exist (although the page (including TOC) is correctly displayed and the TOC links correctly). This is because for the targets of the "edit" links the content of conditionally included templates is considered part of the page itself, and the sections are counted after expansion.

Thus the "edit" links of the sections of the included template link to the page itself instead of the template, and the "edit" links after the included template link to the correct page but the wrong section number.

The problem does not occur when transcluding a template with a conditional name (which has more advantages). Use m:Template:void (backlinks ) for the template to transclude to produce nothing.

The editing facilities can also be applied to a section of an included template. This section, Help:Editing sections of included templates, is an example.

For the purpose of section editing the extent of a section is governed by the headers in the calling page itself. It may consist of a part before the template tag, the template tag, and a part after the template tag, even if the template has sections.

It tends to be confusing if the extent of sections according to the system is different from what the rendered page suggests. To avoid this:

It may be convenient, where suitable, to start a template with a section header, even if normally the contents of the template would not need a division into sections, and thus the template is only one section. The edit facilities for editing sections can then be used for editing the template from a page that includes it, without specially putting an edit link. This template is an example, it does not need a division into sections, but has a header at the top.

One downside with this solution is that you can't change the section level in the page that includes the template. This means that the section level you use in the template will be the same that is displayed on all your pages where you include the template, despite the fact that this might conflict with your intended hierarchy on the different pages.

The __NOEDITSECTION__ tag in any template affects both that template, the pages it's included on, and any other templates included on the same page.

An alternative is (creating a compound document by transclusion). This allows easy searching within the combined rendered page, but not in the combined wikitext. As a disadvantage, a title for each page has to be provided. For the pre-expand include size limit this is disadvantageous even compared with one large page: the pre-expand include size is the sum of the pre-expand include sizes of the components plus the sum of sizes of the wikitexts of the components.

Template-style section transclusion (TST) is an older method of transcluding sections.

Use a template call to transclude the section. For example, to transclude a section called chapter1 from a page called pageX: