Help talk:Section

From Meta, a Wikimedia project coordination wiki

This page used to have multiple TOCs as a demo, but that is no longer supported.

Changing TOC numbering to bulleted list?[edit]

Is there a way of making a TOC display as a bulleted list instead of either the numbering or no numbering format? SImply turning off the TOC numbering (while it thankfully gets rid of the outline numbering) does have its problems visually. Ideally displaying it with bullets instead of numbering (or nothing at all) would bean option. Is there a work around through the common.css to do this? Lestatdelc 06:44, 26 January 2012 (UTC)Reply[reply]

I'm also looking for a solution to remove the numbers. The only solution I've found so far, it to edit the page Wikimedia:common.css with:

.tocnumber { display: none; } But it's not the solution I want. I'm looking for a magic word to create a template.

Duplicate TOCs[edit]

First sentence in this article notwithstanding, is there a way to put duplicate TOCS in a article? Or grab one page's TOC from another? Or use a template or extension to create a de facto TOC?

I have a request for a wikibook I'm putting together to have a fixed-position sidebar that has a expandable, up-to- date TOC always there. Ideally, I could use a template using CustomNavBlocks that would either allow me to move the per article TOC into that position or duplicate it there.

I am also interested in being able to sew together a global dynamic TOC from all the article TOCs in the Main Page of the "book." --Two7s clash 11:00, 20 April 2010 (UTC)Reply[reply]

I'm hoping that someone will answer the first question of this section: is there a way to duplicate the TOC? Having a TOC as the top of a very long page makes for a lot of work for the user. I'd like to put the TOC code at every section (float right). RB

Template Only for Section Headers?[edit]

I have been trying for days (to no avail) to make a template with only the names of section headers to be used as a "headers template" for other pages. This way, all of my pages could have the same basic look and section headers, but I could go back and change only the names of the section headers if I chose to at a later time. Currently, the edit section links always take me back to the template itself, and I can't figure out a suitable workaround. Any help would be greatly appreciated. Thanks in advance. 20:59, 27 July 2007 (UTC)Reply[reply]

This is a known complication, see Help:Section#Editing_sections_of_included_templates. Putting some explanatory text and/or extra edit links on affected pages can be useful.--Patrick (talk) 23:24, 27 July 2007 (UTC)Reply[reply]

Number of levels[edit]

Does anyone know how to change the maximum level of section shown by the TOC?

or change the maximum number of levels supported by the section numbering code?

currently it seems to only take 6 levels of numbering.

Does anyone have an answer to these two questions? i'm in the same boat. I need to have the subsection numbering go above the 6 limit it currently has. Any idea where in the code I can change it?. Roger R Cruz
Since the ToC corresponds to the wiki headers, and the wiki headers are translated into HTML header tags (<h1> through <h6>), you'll have to hack core MediaWiki code to get it to go beyond six. Also, since HTML only uses six levels of headers, you'll have to use different tags (or recycle the header tags using a different class attribute, though I don't recommend this) and figure out what the HTML would be for the seventh and beyond headers. —Sledged (talk) 19:42, 23 May 2007 (UTC)Reply[reply]
Thank you for the in-depth response. This task would be out of my league now but as I become more familiar with the inner workings, I may attempt it one day. Roger R Cruz 16:32, 24 May 2007 (UTC)Reply[reply]

Section numbers[edit]

Is there a way to remove or hide the section numbers from the Table of Contents (TOC)?

I have a document I want to create which already has its own section numbers and thus two sets of section numbers look silly. --Rport

They have a CSS class, class="tocnumber", so people can choose to hide them on all pages. I do not think you can hide them from specific pages.--Patrick 6 July 2005 11:41 (UTC)
There is not a class="tocnumber" that I can find, and I really would like to remove the section numbers.----
These instructions assume familiarity with CSS (if you aren't familiar with CSS, Google is Your Friend ;-).
  • Looking in your skin's main.css file.
  • Search for ".tocnumber" (including the period). If you can't find any instance of it, add the following to your main.css file:
	display: none;
  • Navigate back to your wiki page and reload it (making sure to clear your browser cache if nothing changes at first).
  • Voilá! Your section numbers should be gone.
  • This definitely works for MediaWiki v1.6.8, and should work for any WikiMedia version with the same "tocnumber" class name.
--Shaper 14:47, 31 July 2006 (UTC)Reply[reply]

Is there a way to have the section numbers from the TOC show up in the actual sections themselves? This would be very useful when doing documentation for something on a wiki that you eventually print out.

With the preference setting Auto-number headings sections are numbered. I added that.--Patrick 09:32, 27 August 2006 (UTC)Reply[reply]

Is there a way to specify the starting section number on a page? This would be useful in a document with multiple pages, each with a TOC, to make the section numbering within each page unique across the set of pages. (The icing on this cake would be to be able to "extract" the TOC from several pages and combine them into a master TOC.) Ok, I've figured out how to do that "extract": just create a composite page made up of all those sub-pages (see Help:Composite pages). Voila! The TOCs are merged (naturally) into a composite TOC. AND... the major sections from each subpage are sequentially numbered in the composite TOC. Perfect! So now, I just need to be able to force a specific value as the starting point for section numbering. Anybody???

First section numbered zero?[edit]

Is it possible to make the auto-numbering of sections start at 0 (and the subsections be 0.1, 0.1.1, etc). If not, I suppose I could just use the css trick to remove the section numbers from the TOC and then manually name each of my sections. While this certainly is not the worst option it is less than ideal. Thank you.

Linking to Section numbers instead of names[edit]

I read section help fairly thoroughly and saw the discussion about the 'hidden' id of each section and while I'm not clear on how you figure out the id for a section I'm not sure this would help anyways. What I want to be able to do is use the # prefix to specify a section to jump to but instead of using the section name I want to use the section number. I saw how to do this for editing but I would like to be able to use the same numbering scheme for linking to a section for viewing only. In other words, instead of #section_about_updating_your_sandbox I would like to ref the section with something like #section=3 (assuming that section is the 3rd in the TOC). Thanks! Jmckey 18:30, 2 April 2007 (UTC)Reply[reply]

That does not seem possible. The browser processes "#" with an anchor name, while "section=.." is processed by the server. This parameter seems to apply for "action=edit" only, in it is ignored.--Patrick 20:12, 2 April 2007 (UTC)Reply[reply]
In that case, can anyone think of a way I could add text to a line in the TOC without it affecting the anchor name/link? Something like a comment that does not become part of the actual link/anchor/section name. I want to have comprehensive section names without making linking to each section later a tedious process. I know I can use redirecting, but that seems like a lot of extra maintenance per section that is added. Jmckey 20:42, 5 April 2007 (UTC)Reply[reply]
You can put an anchor (see Help:Link#Anchors) where you like, so also at the start of a section. The name can be chosen independently from the section name.--Patrick 22:16, 5 April 2007 (UTC)Reply[reply]
That should work fine as described. But beware of anchors with spaces in older versions. --Thnidu 20:30, 12 May 2010 (UTC)Reply[reply]

Headings HTML[edit]

Dunno where this belongs, so I'll put it here:

What is the rationale behind the headings structure?

  • The page title is heading 1; the site subtitle is heading 3. Why is the site lower than the page? Why is the subtitle a heading at all?
I'm not sure exactly what you mean, but the Page-heading is H1 because it's (semantically) the most important thing on the page - it tells you what the page is about. The site subtitle is relatively important (or else you wouldn't bother having one), and semantically it's still a heading, hence h3.--Shaper 14:54, 31 July 2006 (UTC)Reply[reply]
  • Why are top-level headings made heading 1 in the HTML, on the same level as the page title, so that most headings are actually level 2?
Because the page-heading is the most important title on the page. "Most headings" are actually subsections of the page title, so they should be a lower-level heading than the page heading.--Shaper 14:54, 31 July 2006 (UTC)Reply[reply]
So that when a user without CSS, or a text-mode browser, or a screen reader visits, they'll be presented with a page that at least has a logical document flow. Rob Church Talk 07:42, 8 December 2005 (UTC)Reply[reply]
Exactly - they're still "headings", and so still deserve an "hX" tag, but (in the cosmic scheme of things) they aren't that important, so they have a low-level heading ("h5").--Shaper 14:54, 31 July 2006 (UTC)Reply[reply]

Style placing [edit] into page?[edit]

Hi! I would like to know a code of the style which places [edit] into the page to each section. Where can I find it, if any such a code exists? Thank you! Miraceti 15:41, 9 December 2005 (UTC)Reply[reply]

Look for the "editsection" class. --Pmsyyz 02:26, 11 January 2006 (UTC)Reply[reply]

Section Numbering[edit]

How do I remove the numbers from the Section headers? --Latinlives 19:08, 25 February 2006 (UTC)Reply[reply]

My guess is that removing the section numbering can only be done in CSS, perhaps setting up you own User styles might help. -- Rport

Hiding Sections[edit]

Is there any way to hide a section, so that it expands on a click, like the TOC does? -- 19:16, 1 March 2006 (UTC)Reply[reply]

See Template:Hidden.--Patrick 08:33, 11 March 2006 (UTC)Reply[reply]

Sub-page TOCs[edit]

Is it possible, if you have a list of links to sub-pages, to display each of these sub-page TOCs on the upper-level page? -- 17:28, 11 March 2006 (UTC)Reply[reply]

By putting __TOC__ where ever you want a table of contents. If you have 4 or fewer headings you can use __FORCETOC__ to display the contents

You can create a "master" TOC by creating a composite page (see Help:Composite pages). The section numbering even comes out sequentially (on the composite page that is.) Ideal would be if you could specifiy a starting section number on each sub-page, so they would match the numbering in the composite TOC.) Anybody know how to do that??

I need help[edit]

I made my page, it has Sectionsd and sub sections and stuff, but how doI make teh table of contents thing at teh top?

When do the Edit links appear?[edit]

I have some pages where the Edit link does not appear for each section heading. How do I turn them on? - JohnE

Section size[edit]

What are the minimum and maximum limits on section size? I don't find anything at Help:Section or Wikipedia:Article size. Perhaps there was more information at w:Wikipedia:Guide_to_layout#Structure_of_the_article? Hyacinth 19:14, 15 May 2006 (UTC)Reply[reply]

Limiting subsection levels shown in TOC[edit]

If you would like to have a heading not show up in the generated Table of Contents at the top of the page, you can use HTML to make the header... or at least that worked in older versions!

Unfortunately it doesn't seem to any more (at least, not in 1.6.8). The developers don't seem to give a reason for it, either, nor want to explain why they chose to restrict the functionality in this way. Most annoying.
Anyone else have any idea how to do it, short of writing a new extension for MediaWiki? --Shaper 14:57, 31 July 2006 (UTC)Reply[reply]
As seen in the article Help:Wikitext examples, one way is to wrap the section heading in HTML span tags that specify the same style as the wiki uses. The problem I see with that is that those headings won't look right if wiki's stylesheets are changed later. I propose that an extension to the wikitext markup for section headings be created to allow section headings be marked for TOC exclusion. It would need to be something that would be least likely to break current markup, though. Maybe adding an exclamation point followed by a space, like:
===! Section heading ===
--Lsloan 17:44, 22 August 2008 (UTC)Reply[reply]
I'd rather see something else, by allowing style and other attributes to be specified for sections headings, like this:
==| class="..." style="..." lang="..." dir="..." id="A" -wiki-number="A." -wiki-number-style="display:inline" | Section A. heading ==
===|id="A1" -wiki-toc="ignored" -wiki-number="(1)" -wiki-number-style="display:inline"| Subsection (1) heading ===
===|id="A2" -wiki-toc="ignored" -wiki-number="(2)" -wiki-number-style="display:inline"| Subsection (2) heading ===
i.e. it would work for sections that contain at least two vertical bars, and where the first bar must come immediately after the last equal sign of the section prefix, without any space separator.
spaces are still allowed anywhere between the two vertical bars for the additional attributes.
This means that the following simple section heading:
==Section heading==
== Section heading ==
would become completely equivalent to:
==||Section heading==
==|| Section heading ==
There's much less risk that it will conflict with existing section titles (that don't seem to use any vertical bar).
Note that if a section heading really needs a vertical bar in its first character, you just have to write it this with a space before it:
== |Section heading==
or equivalently (and more robustly) as:
==|| |Section heading ==
or even (for those that already prefer no space between the initial == tag and the final == tag):
==|||Section heading==
This way you can specify an alternate id (in addition to the default id generated for the TOC in the HTML h1...h6 element start tags: it will add an empty anchor automatically).
In addition, some specific "-wiki-" attributes would allow to specify how the section gets numbered in the TOC, or if the numbering should be visible (useful for WikiSources or WikiBooks, to keep the original TOC numbering), using -wiki-number="..." with any convenient numbering string for the TOC, -wiki-toc="include|ignore" ("include" by default), -wiki-number-style="..." for controlling the style of the section number if shown in the section heading.
The specific -wiki- attributes would be converted also in XHTML as regular XML attributes using a "mediawiki:" XML namespace prefix (the namespace "mediawiki" could be declared in the XML/XHTML document header and possibly also the full names of attributes with the "mediawiki:" prefix, in the embedded initial DTD for HTML validators), allowing personal stylesheets to work also with them and change the preferences.
verdy_p 11:25, 17 November 2008 (UTC)Reply[reply]

master Talk pages?[edit]

On it says do not edit this page. It should mention if editing the discussion page is OK or not. --User:Jidanni 2006-07-26

Nowhere does it say to not edit this page. It only says not to edit the Wikipedia copy. Brian Jason Drake 01:50, 21 May 2007 (UTC)Reply[reply]

Template for unnumbered (no TOC?) sections[edit]

There's an article where I want a couple of sections to have headers, and then a series of numbered sections. That is, I want something roughly like

  more text
  more text
  still more text

It would be nice if the first two headers were in the TOC and had section-edit links, but it isn't critical. What's critical is getting the numbering as shown.

Help:Section#Text in a large font that should not begin a section suggests

  <b><span style="font-size:120%"> Example text </span></b>

but it seems wrong to embed that kind of thing, and in particular the constant 120%, into an article. It seems like there should either be a special syntax for this, or a template that arranges for the right things to happen.

I've got a template that comes close, but the bottom border line doesn't go all the way across like the "real" section headers' does:

    <p style="padding-top: .5em;">
    <span style="font-size:150%;border-bottom: 1px solid #aaa;">

You use this template by saying

   {{User:Jordan Brown/noTOCsection|My Header}}

One might think that you could just use <h2>, but it appears that MediaWiki is too smart for its own good, and puts <h2> stuff into the TOC anyway.

I'm a MediaWiki beginner and only a little better with CSS. (My HTML is pretty good.)

Anybody have any ideas?

Jordan Brown 07:26, 13 October 2006 (UTC)Reply[reply]

Help with sections[edit]

I've got a problem involving sections. Basically, the = and == header comes with a line divider automatically.

What i need is for the === header to come with a line divider. We've tried adding a ---- below the === header to create the line divider, but it doesn't really work. What we get is a very obvious gap between the header and the line divider.

Is there any way at all to create a === heading that has a ---- divider incorporated into it?

If you want it to come with a line everywhere, you could remove 'h3' from this part of main.css (Line 140 here)
h3, h4, h5, h6 { border-bottom: none; font-weight: bold;} 13:25, 11 April 2007 (UTC)Reply[reply]

Wrapping Text Around the ToC[edit]

Is there any (convenient) way to make the article text wrap around the ToC? —Sledged (talk) 17:04, 19 March 2007 (UTC)Reply[reply]


Is there such a thing as a horizontal toc? I've looked a lot of places now - and I can't seem to find one, but I figure if anyone knew you guys would. One problem is I can't do this like a css type of thing - any user that comes has to see it horizontally. I was hoping for something like this (with less space in between words):

Table of Contents
Welcome to Wikimedia! Great Job on your First edit! Can I have your Opinion Your first barnstar
You have been elected to an admin position You have been elected to the Jimbo position WHAT WERE YOU THINKING? WE'RE RUINED! Thanks to you I won't ever trust people to edit MY wiki again

Thanks for any help! 20:31, 5 April 2007 (UTC)Reply[reply]

<div class="horizontal">
</div> 17:05, 8 April 2007 (UTC)Reply[reply]


I suggest create the magic word TOC_FORWARD to show the TOC of the text that appears bellow the magic word (this can include the content of a transcluded template). See an example at commons:Commons:Picture_requests where the sections table of Add request, Upload requested image and See also wouldn´t appear in the page - this is, TOC goes backwards - ). -- 10:44, 5 May 2007 (UTC)Reply[reply]

Listing TOC of Other Pages[edit]

I would like to be able to list the TOC of another page on a different page. I don't know if this is possible, I have been searching and cannot find it. Ideally it would be something like: __TOC:Page_Name__

That is not possible.--Patrick 10:58, 21 May 2007 (UTC)Reply[reply]

Is there an alternative to this then? For example, I want to keep things basic. I want my main page to be a "gateway" to the rest of my content. It would be much easier to just include the TOC of the other pages on the main page so I can just click to where I need to go. Otherwise, I have to update the information on the target page and update it again on the "primary index." Suggestions?

This doesn't look very hopeful -- 3½ years and no solution! -- but I would also like to be able to do this. I keep a "to do" page and transclude it to the bottom of my monthly log as a section. I'd like to have the TOC of the to-do page appear at the head of its section on the monthly log, but then I get a repeat of the TOC of the entire log page. Any help? -- Thnidu 15:33, 26 October 2010 (UTC)Reply[reply]

Header Parsing Code[edit]

One thing I like about the headers is that, if I have the following:

==='''[[some page|Header Text]] More ''Text'''''===

It's smart enough to strip out all the markup and hyperlinking from the text to create an anchor with the name "Header Text More Text." Does MediaWiki have a mechanic (outside of using headers) or extension for boiling markup down to just the resulting text? If not can anyone point to me where in the source code it does this so I can extract it and use in an extension? —Sledged (talk) 19:52, 23 May 2007 (UTC)Reply[reply]

It actually fails to do that smart stuff consistently, esp. with image parameters. Images in headings are not used in articles, but they are common in WikiProject headings, e.g. those at w:Wikipedia:WikiProject Cue sports#Articles within this WikiProject's scope; edit any of the subsections under that and you'll see what I mean. For example, one shows /* Featured Article former candidates 20px */ in the edit summary instead of /* Featured Article former candidates */ (the wikicode is [[:WP:FA|Featured Article]] former candidates [[Image:Cscr-former.png|20px]]). Not the most common case in the world, but clearly a bug. — SMcCandlish [talk] [cont] ‹(-¿-)› 15:59, 30 November 2007 (UTC)Reply[reply]

A-Z-style horizontal TOC template redundancy cleanup at Wikipedia[edit]

Could use some input from editors who think about this sort of thing.

Short version: There are 8 templates of this sort at WP, and most have been functionally merged into one; there is an active TfD to clean up, but it is garnering little comment.

SMcCandlish [talk] [cont] ‹(-¿-)› 15:54, 30 November 2007 (UTC)Reply[reply]

A better float of TOC[edit]

The Table of contents can be forced onto a floating table on the right hand of the screen with the code below:  {| align="right" | __TOC__ |}

That is however an abuse of HTML-tables. A much better practice would be to use CSS and a div-element instead, which also may provide a greater degree of control. Example:

  <div style="float: right; margin: 0 1em 1em 2em; width: 40%">

-- 13:15, 18 February 2008 (UTC) en:itpastornReply[reply]

Adding a new section at the beginning?[edit]

Hi, is there a possibility to edit a new section at the beginning instead of the end of a page? -- 15:12, 12 August 2008 (UTC)Reply[reply]

You can of course simply edit the page and add the section to the top, but I guess you mean using the new section link? You could try asking that at mw:Project:Support desk. --Erwin(85) 15:39, 12 August 2008 (UTC)Reply[reply]
Ah...yeah, you're right. Of course I mean't the new section link. Thanks! -- 16:15, 12 August 2008 (UTC)Reply[reply]

Return to TOC[edit]

It would be nice if the section heading had a "Return to TOC" hyperlink. This link should reveal the position of this section in the table of contents. --Yecril71pl 12:46, 7 September 2008 (UTC)Reply[reply]

Show the TOC instead of section name[edit]

Is there any possibility to show the contents of TOC instead the section name?

An example like see {{#section}}, results in see 1.4.5. -- 19:27, 19 September 2009 (UTC)Reply[reply]

id with space in it doesn't work in older versions[edit]

My workplace still uses v1.4.10 for its internal wiki, but I've got them up to date on another one I'm working on. I just found a bug in the older version, fixed sometime between then and now. See Section linking, the paragraph beginning "To create an anchor target". -- Thnidu 20:25, 12 May 2010 (UTC)Reply[reply]

__FORCEEDITSECTION__ would be helpful[edit]

In articles the section edit links are disturbing the layout, so we generally switch them off. On some pages however they are quite useful. So why is no magic word like __FORCEEDITSECTION__ provided? Is there another workaround for this? Bye -- 04:03, 30 October 2010 (UTC) (Rob)Reply[reply]

Confusing explanation[edit]

In the following text: "Headers with only one equals sign on a side (=text here=) should only be used sparingly and in prescribed circumstances; this causes a title the size of the page name, which is taken care of automatically. Also, when you create a section header, you can't have other content on the same line. For example ==Section Header==
will not work."

I am a bit confused. What is wrong with using single = headers? Just that the text is the same size as the page title? The phrase "which is taken care of automatically" is not clear. Also, the second part "Also, when you create a section header, you can't have other content on the same line. For example ==Section Header==
will not work." Seems to be completely unrelated to the headers with one =, but the paragraph reads as though they are connected. If I am correct, this should be broken into two bullets or something like that.

Thoughts? Daviddoria 18:19, 18 November 2010 (UTC)Reply[reply]

I changed it.--Patrick (talk) 21:24, 18 November 2010 (UTC)Reply[reply]

ifexist for sections[edit]

There is a parser function ifexist that allows one to modify the outcome of a template depending on where a page exists or not. Is there anything like that for the existence of a section?

Alternatively: if I put a certain section of a page inside wiki- brackets on the page itself, I get a blue link regardless of whether that section actually exists on the page.

Can that be changed to red when the section is not there?

Jcwf 18:26, 15 December 2010 (UTC)Reply[reply]

mediawiki - Sections HTML code convertion problem[edit]

Greetings ... im havving a REALLY annoying problem. I have my wiki in a local server and in an server somewhere else.

The CSS are exacly the same BUT, on my local wiki the sections text are in blue (correct) and in the outside server are in black (wrong). even if i modify the main.css in the outside server in wont change to blue. if i apply any other stype, line background color, or underline, etc .. it will apply, but the color it refuses to change. i even tryied to use "!importante" and nothing (locally the the !import works just fine).

I looked into the generated page code to try to figure it out and this is that i found:

In my local server, the section generated code looks like this

	<span class="mw-headline" id="Overview"> Overview </span>

In the other end ... on my external server the section generated code looks like this

	<span class="mw-headline" id="Overview">
		<a style="text-decoration:none;color:black" name="Overview"> Overview </a>

So.. i am almost sure that the problem is the style defined in the anchor. the question is .. why is that there??? i also found something interesting that may be a clue (for someone but not for me)

I found 2 wikis refering to "Help:Section"
in this one, they say that section work like in my local wiki
in this one (the one we are right now) it says that it works like on my external server

Is this any clue to anyone?

Thanks in advance for any help you can give me.

- Miguel (17-02-2011 14:34)

fixed demo section link[edit]

I forgot to annotate my edit just now:

In Help:Section#Section_linking_with_arbitrary_id, under "Notes", there was a demo link to Demo a, but there was no section "Demo a" to link to: just Demo abc. So I fixed the demo link. --Thnidu (talk) 15:46, 5 August 2013 (UTC)Reply[reply]

Editing H4+[edit]

Is there a way, via magic word or otherwise, to make a section made with four or more "=" on either side individually editable via an "[edit]" button? Schiffy (talk) 03:03, 14 December 2016 (UTC)Reply[reply]