In today's article, we will explore the fascinating world of Template:Static row numbers. From its origins to its impact on modern society, we will delve into its history, evolution and relevance in today's world. Template:Static row numbers is a topic that has aroused interest and curiosity over time, and throughout this article, we will try to shed light on its most significant aspects. With expert interviews, in-depth analysis and practical examples, we aim to offer a comprehensive and insightful view of Template:Static row numbers, so that our readers can expand their knowledge and better understand its importance in different contexts. Get ready to enter a world of discoveries and reflections on Template:Static row numbers!
| This template uses TemplateStyles: |
This template adds a column of row numbers to a table. The numbers do not sort with the rest of the table, remaining static. Optional classes are provided to display a column label or disable numbers on specific rows.
It works on desktop and mobile versions of Wikipedia pages.
Include this template by adding {{static row numbers}} or its redirect {{static-row-numbers}} above a table. Add the static-row-numbers class to the table start wikitext. Optionally add the other classes listed below.
Wikitext:
{{static row numbers}}
{| class="static-row-numbers"
| Table class | Summary |
|---|---|
static-row-numbers
|
Required. Displays a column of row numbers aligned right. Requires at least one header row. |
static-row-numbers-center
|
Center aligns numbers. Default right. |
static-row-numbers-left
|
Left aligns numbers. Default right. |
static-row-header-text
|
Displays "No." text in column label. |
static-row-header-hash
|
Displays hash ("#") symbol in column label. |
| Table attribute | Summary |
|---|---|
data-srn-limit="N"
|
Remove numbers beyond row N of the sortable data where N is the number 10. Requires sortable table. Unpredictable results when adding sorttop (uses static-row-header) rows above or static-row-numbers-norank rows in the sortable data. Example: {| class="static-row-numbers" data-srn-limit="10".
|
| Row class | Summary |
|---|---|
static-row-header
|
Disables a row number. Disables borders between consecutive row usages (simulates rowspan). Add to sorttop and sortbottom rows. Add to header rows except the first.
|
static-row-numbers-norank
|
Disables a row number. Maintains borders between consecutive row usages. Optionally add to data rows. |
Multiple header rows in a sortable table should have the static-row-header class added to all header rows except the first one so that they are not numbered when JavaScript is disabled. It is also needed on rows that use the sorttop or sortbottom class, described at #Disable number on specific rows.
Wikitext:
{{static row numbers}}
{| class="wikitable sortable static-row-numbers"
|-
! rowspan="2" | Color
! colspan="3" | Data
|- class="static-row-header"
! A !! B !! C
|-
| Red || 1 || 2 || 3
|-
| Lime || 4 || 5 || 6
|-
| Gold || 7 || 8 || 9
|- class="sortbottom static-row-header"
| '''Total''' || 12 || 15 || 18
|- class="sortbottom static-row-header"
| '''Average''' || 4 || 5 || 6
|}
Produces:
| Color | Data | ||
|---|---|---|---|
| A | B | C | |
| Red | 1 | 2 | 3 |
| Lime | 4 | 5 | 6 |
| Gold | 7 | 8 | 9 |
| Total | 12 | 15 | 18 |
| Average | 4 | 5 | 6 |
Multiple header rows in a non-sortable table should have the static-row-header class added to all header rows except the first one, described at #Disable number on specific rows.
Wikitext:
{{static row numbers}}
{| class="wikitable static-row-numbers"
|-
! rowspan="2" | Color
! colspan="3" | Data
|- class="static-row-header"
! A !! B !! C
|-
| Red || 1 || 2 || 3
|-
| Lime || 4 || 5 || 6
|-
| Gold || 7 || 8 || 9
|}
Produces:
| Color | Data | ||
|---|---|---|---|
| A | B | C | |
| Red | 1 | 2 | 3 |
| Lime | 4 | 5 | 6 |
| Gold | 7 | 8 | 9 |
To display the "No." text in the number column's header (label), add the static-row-header-text class to the table start wikitext.
Wikitext:
{{static row numbers}}
{| class="wikitable static-row-numbers static-row-header-text"
|-
! rowspan="2" | Color
! colspan="3" | Data
|- class="static-row-header"
! A !! B !! C
|-
...
Produces:
| Color | Data | ||
|---|---|---|---|
| A | B | C | |
| Red | 1 | 2 | 3 |
| Lime | 4 | 5 | 6 |
| Gold | 7 | 8 | 9 |
To display a hash ("#") symbol in the number column's header (label), add the static-row-header-hash class to the table start wikitext.
Wikitext:
{{static row numbers}}
{| class="wikitable static-row-numbers static-row-header-hash"
|-
! rowspan="2" | Color
! colspan="3" | Data
|- class="static-row-header"
! A !! B !! C
|-
...
Produces:
| Color | Data | ||
|---|---|---|---|
| A | B | C | |
| Red | 1 | 2 | 3 |
| Lime | 4 | 5 | 6 |
| Gold | 7 | 8 | 9 |
This section details how to disable numbers on specific rows by adding either the static-row-numbers-norank or static-row-header class to the row wikitext.
The static-row-numbers-norank class can be added to data rows to disable the number.
The static-row-header class disables the number and border between other rows that use this class consecutively, simulating a rowspan (see Help:Table#Colspan and rowspan). It should be added to:
sorttop or sortbottom class.Note, the sorttop or sortbottom class is added to a row so it stays at the top or bottom of a sorted list, per Help:Sortable tables.
Wikitext:
{{static row numbers}}
{| class="wikitable sortable static-row-numbers"
|-
! rowspan="2" | Color
! colspan="3" | Data
|- class="static-row-header"
! A !! B !! C
|- class="sorttop static-row-header"
| '''Min''' || 1 || 2 || 3
|- class="sorttop static-row-header"
| '''Max''' || 10 || 11 || 12
|-
| Red || 1 || 2 || 3
|- class="static-row-numbers-norank"
| Lime || 4 || 5 || 6
|- class="static-row-numbers-norank"
| Gold || 7 || 8 || 9
|-
| Blue || 10 || 11 || 12
|- class="sortbottom static-row-header"
| '''Total''' || 22 || 26 || 30
|- class="sortbottom static-row-header"
| '''Average''' || 5.5 || 6.5 || 7.5
|}
Produces:
| Color | Data | ||
|---|---|---|---|
| A | B | C | |
| Min | 1 | 2 | 3 |
| Max | 10 | 11 | 12 |
| Red | 1 | 2 | 3 |
| Lime | 4 | 5 | 6 |
| Gold | 7 | 8 | 9 |
| Blue | 10 | 11 | 12 |
| Total | 22 | 26 | 30 |
| Average | 5.5 | 6.5 | 7.5 |
This section details how to remove numbers beyond a certain limit by adding the data-srn-limit="N" attribute and value to the table wikitext, where N is a number limited to certain values according to the "Usage" section above. 10 is one allowed value used in this section.
Due to limitations in CSS (styles), there are some restrictions to make it work properly. The table needs to use the sortable class so column headers are moved out of the sortable area (<tbody> element) to exclude them from the count. Avoid adding sorttop (uses static-row-header) rows above the sortable data since they aren't excluded from the count before sorting. Avoid adding static-row-numbers-norank rows in the sortable data since they aren't excluded from the count when ordered within the numbered limit.
Wikitext:
{{static row numbers}}
{| class="wikitable sortable static-row-numbers" data-srn-limit="10"
|-
! rowspan="2" | Color
! colspan="3" | Data
|- class="static-row-header"
! A !! B !! C
|-
| Red || 1 || 2 || 3
|-
| Lime || 4 || 5 || 6
|-
| Gold || 7 || 8 || 9
|-
| Blue || 10 || 11 || 12
|-
| Orange || 2 || 9 || 5
|-
| Yellow || 3 || 7 || 4
|-
| Green || 5 || 6 || 2
|-
| Purple || 6 || 4 || 1
|-
| Pink || 8 || 3 || 7
|-
| Black || 9 || 2 || 8
|-
| White || 11 || 1 || 10
|-
| Gray || 12 || 12 || 11
|- class="sortbottom static-row-header"
| '''Total''' || 78 || 70 || 78
|- class="sortbottom static-row-header"
| '''Average''' || 6.5 || 5.8 || 6.5
|}
Produces:
| Color | Data | ||
|---|---|---|---|
| A | B | C | |
| Red | 1 | 2 | 3 |
| Lime | 4 | 5 | 6 |
| Gold | 7 | 8 | 9 |
| Blue | 10 | 11 | 12 |
| Orange | 2 | 9 | 5 |
| Yellow | 3 | 7 | 4 |
| Green | 5 | 6 | 2 |
| Purple | 6 | 4 | 1 |
| Pink | 8 | 3 | 7 |
| Black | 9 | 2 | 8 |
| White | 11 | 1 | 10 |
| Gray | 12 | 12 | 11 |
| Total | 78 | 70 | 78 |
| Average | 6.5 | 5.8 | 6.5 |
More template styles for tables: