வார்ப்புரு:Static row numbers/doc
{{Documentation subpage}}
 &lt;!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata --&gt;
 {{tsh|srn}}{{Uses TemplateStyles|Template:Static row numbers/styles.css}}
 :'''''Note:''' [[:Category:Articles with tables with fixed row numbers]] uses a deprecated template. Please replace it with {{tl|Static row numbers}}.''
 
 Template to automatically add row numbers to sortable tables. The row numbers will not be sorted when columns of data are sorted. A possible note to add above a table: &lt;code&gt;{{tlx|noprint|&lt;nowiki&gt;'''''Row numbers''' are static. Other columns are sortable. This allows ranking of any column.''&lt;/nowiki&gt;}}&lt;/code&gt;
 
 These templates work together and make table formatting fast: 
 *{{tl|Static row numbers table}}
 *{{tl|Static row numbers header}}
 *{{tl|Static row numbers arrows}}
 *{{tl|Static row numbers no rank}}
 *{{tl|Static row numbers total}}
 Some are used together here: [[List of U.S. states and territories by incarceration and correctional supervision rate]]
 __TOC__
 
 == Usage with &lt;code&gt;wikitable&lt;/code&gt; and &lt;code&gt;sortable&lt;/code&gt; ==
 
 Place template before table where the automatic row numbers are required. Add class &lt;code&gt;static-row-numbers&lt;/code&gt; to the table wikitext, as in the following example. It adds an unsorted column of row numbers.
 
 {| style=&quot;border:solid 1px;&quot;
 |+ With &lt;code&gt;wikitable&lt;/code&gt; and &lt;code&gt;sortable&lt;/code&gt; 
 |-
 |
 {{Static row numbers}}
 {| class=&quot;wikitable sortable static-row-numbers&quot;
 ! Name !! Number !! Another Number
 |-
 | A || 10 || 1000
 |-
 | B || 50 || 800
 |-
 | C || 100 || 150
 |-
 | D || 20 || 700
 |-
 | E || 70 || 350
 |}
 |
 &lt;syntaxhighlight lang=&quot;wikitext&quot; highlight=1-2&gt;
 {{Static row numbers}}
 {| class=&quot;wikitable sortable static-row-numbers&quot;
 ! Name !! Number !! Another Number
 |-
 | A || 10 || 1000
 |-
 | B || 50 || 800
 |-
 | C || 100 || 150
 |-
 | D || 20 || 700
 |-
 | E || 70 || 350
 |}
 &lt;/syntaxhighlight&gt;
 |}
 
 == Usage with &lt;code&gt;sortable&lt;/code&gt; ==
 
 {| style=&quot;border:solid 1px;&quot;
 |+ With &lt;code&gt;sortable&lt;/code&gt;
 |-
 |
 {{Static row numbers}}
 {| class=&quot;sortable static-row-numbers&quot;
 ! Name !! Number !! Another Number
 |-
 | A || 10 || 1000
 |-
 | B || 50 || 800
 |-
 | C || 100 || 150
 |-
 | D || 20 || 700
 |-
 | E || 70 || 350
 |}
 |
 &lt;syntaxhighlight lang=&quot;wikitext&quot; highlight=1-2&gt;
 {{Static row numbers}}
 {| class=&quot;sortable static-row-numbers&quot;
 ! Name !! Number !! Another Number
 |-
 | A || 10 || 1000
 |-
 | B || 50 || 800
 |-
 | C || 100 || 150
 |-
 | D || 20 || 700
 |-
 | E || 70 || 350
 |}
 &lt;/syntaxhighlight&gt;
 |}
 
 == Usage with no other classes ==
 
 While designed to provide a static row number for sortable tables, it can be used just to add an automatic row number to plain tables.
 
 {| style=&quot;border:solid 1px;&quot;
 |+ With no other classes
 |-
 |
 {{Static row numbers}}
 {| class=&quot;static-row-numbers&quot;
 ! Name !! Number !! Another Number
 |-
 | A || 10 || 1000
 |-
 | B || 50 || 800
 |-
 | C || 100 || 150
 |-
 | D || 20 || 700
 |-
 | E || 70 || 350
 |}
 |
 &lt;syntaxhighlight lang=&quot;wikitext&quot; highlight=1-2&gt;
 {{Static row numbers}}
 {| class=&quot;static-row-numbers&quot;
 ! Name !! Number !! Another Number
 |-
 | A || 10 || 1000
 |-
 | B || 50 || 800
 |-
 | C || 100 || 150
 |-
 | D || 20 || 700
 |-
 | E || 70 || 350
 |}
 &lt;/syntaxhighlight&gt;
 |}
 
 == Using &lt;code&gt;static-row-header-text&lt;/code&gt; to add a &quot;No.&quot; column header ==
 
 This adds a '''&quot;No.&quot;''' as the row number column header. Add '''''class=static-row-header-text''''' to the top line of the table wikitext. It does not work with {{tl|Static row numbers table}}.
 
 {| style=&quot;border:solid 1px;&quot;
 |+ With &lt;code&gt;static-row-header-text&lt;/code&gt; to add a column header
 |-
 |
 {{Static row numbers}}
 {| class=&quot;wikitable sortable static-row-numbers static-row-header-text&quot;
 ! Name !! Number !! Another Number
 |-
 | A || 10 || 1000
 |-
 | B || 50 || 800
 |-
 | C || 100 || 150
 |-
 | D || 20 || 700
 |-
 | E || 70 || 350
 |}
 |
 &lt;syntaxhighlight lang=&quot;wikitext&quot; highlight=1-2&gt;
 {{Static row numbers}}
 {| class=&quot;wikitable sortable static-row-numbers static-row-header-text&quot;
 ! Name !! Number !! Another Number
 |-
 | A || 10 || 1000
 |-
 | B || 50 || 800
 |-
 | C || 100 || 150
 |-
 | D || 20 || 700
 |-
 | E || 70 || 350
 |}
 &lt;/syntaxhighlight&gt;
 |}
 
 == Using &lt;code&gt;static-row-header-hash&lt;/code&gt; to add a hash (&quot;#&quot;) column header ==
 
 This adds a hash (&quot;#&quot;) as the row number column header. 
 
 {| style=&quot;border:solid 1px;&quot;
 |+ With &lt;code&gt;static-row-header-hash&lt;/code&gt; to add a column header
 |-
 |
 {{Static row numbers}}
 {| class=&quot;wikitable sortable static-row-numbers static-row-header-hash&quot;
 ! Name !! Number !! Another Number
 |-
 | A || 10 || 1000
 |-
 | B || 50 || 800
 |-
 | C || 100 || 150
 |-
 | D || 20 || 700
 |-
 | E || 70 || 350
 |}
 |
 &lt;syntaxhighlight lang=&quot;wikitext&quot; highlight=1-2&gt;
 {{Static row numbers}}
 {| class=&quot;wikitable sortable static-row-numbers static-row-header-hash&quot;
 ! Name !! Number !! Another Number
 |-
 | A || 10 || 1000
 |-
 | B || 50 || 800
 |-
 | C || 100 || 150
 |-
 | D || 20 || 700
 |-
 | E || 70 || 350
 |}
 &lt;/syntaxhighlight&gt;
 |}
 
 == Marking additional header and footer rows with &lt;code&gt;static-row-header&lt;/code&gt; ==
 
 The class &lt;code&gt;static-row-header&lt;/code&gt; is added to additional header rows (other than the first one). It prevents those header rows from having row numbers. It also prevents them from being sorted. It is important to add this class for consistent appearance in different Wikipedia skins and views. It is necessary for correct numbering in the minerva skin on mobile view which renders HTML tables differently. 
 
 {| style=&quot;border:solid 1px;&quot;
 |+ Marking additional header and footer rows with &lt;code&gt;static-row-header&lt;/code&gt;
 |-
 |
 {{Static row numbers}}
 {| class=&quot;wikitable sortable static-row-numbers&quot;
 ! Name !! Number !! Another Number
 |- class=&quot;static-row-header&quot;
 !  !! (unit) !! (per capita)
 |-
 | A || 10 || 1000
 |-
 | B || 50 || 800
 |-
 | C || 100 || 150
 |-
 | D || 20 || 700
 |-
 | E || 70 || 350
 |- class=&quot;static-row-header&quot;
 ! Totals !! 250 !! 3000
 |}
 |
 &lt;syntaxhighlight lang=&quot;wikitext&quot; highlight=1-2,4,16&gt;
 {{Static row numbers}}
 {| class=&quot;wikitable sortable static-row-numbers&quot;
 ! Name !! Number !! Another Number
 |- class=&quot;static-row-header&quot;
 !  !! (unit) !! (per capita)
 |-
 | A || 10 || 1000
 |-
 | B || 50 || 800
 |-
 | C || 100 || 150
 |-
 | D || 20 || 700
 |-
 | E || 70 || 350
 |- class=&quot;static-row-header&quot;
 ! Totals !! 250 !! 3000
 |}
 &lt;/syntaxhighlight&gt;
 |}
 
 == Marking footer or header rows that also contain data cells (non-header cells) ==
 
 To prevent them from sorting &lt;code&gt;class=sorttop&lt;/code&gt; or &lt;code&gt;class=sortbottom&lt;/code&gt; must also be added. For an example of header rows like this see [https://en.wikipedia.org/w/index.php?title=COVID-19_pandemic_deaths&amp;oldid=1038165297#2021 this version] of the 2021 table in [[COVID-19 pandemic deaths#2021|this list article]].
 
 {| style=&quot;border:solid 1px;&quot;
 |+ Marking footer or header rows that also contain data cells (non-header cells)
 |-
 |
 {{Static row numbers}}
 {| class=&quot;wikitable sortable static-row-numbers&quot;
 ! Name !! Number !! Another Number
 |- class=&quot;static-row-header&quot;
 !  !! (unit) !! (per capita)
 |-
 | A || 10 || 1000
 |-
 | B || 50 || 800
 |-
 | C || 100 || 150
 |-
 | D || 20 || 700
 |-
 | E || 70 || 350
 |- class=&quot;sortbottom static-row-header&quot;
 ! Totals 
 || 250 || 3000
 |}
 |
 &lt;syntaxhighlight lang=&quot;wikitext&quot; highlight=1-2,4,16&gt;
 {{Static row numbers}}
 {| class=&quot;wikitable sortable static-row-numbers&quot;
 ! Name !! Number !! Another Number
 |- class=&quot;static-row-header&quot;
 !  !! (unit) !! (per capita)
 |-
 | A || 10 || 1000
 |-
 | B || 50 || 800
 |-
 | C || 100 || 150
 |-
 | D || 20 || 700
 |-
 | E || 70 || 350
 |- class=&quot;sortbottom static-row-header&quot;
 ! Totals 
 || 250 || 3000
 |}
 &lt;/syntaxhighlight&gt;
 |}
 
 == White background for data cells ==
 
 Add &lt;code&gt;class=srn-white-background&lt;/code&gt; to the top line of the table  wikitext. It can be used on tables with inline cell or row background colors. Neither are affected by this class. 
 
 This class is unnecessary if you are using this:
 *'''{{tl|Static row numbers table}}'''
 The class is incorporated into that template. 
 
 {| style=&quot;border:solid 1px;&quot;
 |+ White background for data cells 
 |-
 |{{Static row numbers}}
 {| class=&quot;wikitable sortable static-row-numbers srn-white-background&quot;
 |-
 ! 1 !! 2 !! 3
 |-
 | 1-1 || 2-1 || 3-1
 |-
 | 1-2 || 2-2 || 3-2
 |}
 |
 |&lt;syntaxhighlight lang=&quot;wikitext&quot; highlight=1-2&gt;
 {{Static row numbers}}
 {| class=&quot;wikitable sortable static-row-numbers srn-white-background&quot;
 |-
 ! 1 !! 2 !! 3
 |-
 | 1-1 || 2-1 || 3-1
 |-
 | 1-2 || 2-2 || 3-2
 |}
 &lt;/syntaxhighlight&gt;
 |}
 
 == See also ==
 * {{tl|Sorting row}} - a way to add a sorting row with centered sorting icons without using any {{tl|Static row numbers}} templates or sub-templates.
 
 &lt;includeonly&gt;{{sandbox other||
 &lt;!-- Categories below this line; interwikis at Wikidata --&gt;
 [[Category:Table templates]]
 [[Category:Templates using TemplateStyles to style external elements]]
 }}