Wikipedia talk:Manual of Style/Accessibility/Data tables tutorial: Difference between revisions

Content deleted Content added
Dodoïste (talk | contribs)
Unbulleted lists: some ideas
Line 131:
::# At a second thought, the widths are set to create a cellpadding. And ems doesn't work in the width attribute. Maybe the % would be a good solution but I'm not sure. Is there a reason why <code>cellpadding="5"</code> doesn't work with <code>class="wikitable"</code>? Cellpadding would definitely be the simplest solution.
::# If cellpadding are used it also solves the issue with centered text as text becomes centered by default: <code>align=center</code> becomes useless. Regards, [[User:Dodoïste|Dodoïste]] ([[User talk:Dodoïste|talk]]) 17:29, 12 September 2010 (UTC)
{{outdent}}
The element 'td' has a deprecated attribute 'width' which can only be a number or a percentage. The number is taken as a 'hint' for number of pixels, and the percentage is a 'hint'
for the percentage of the table width. Neither of them is a good idea, and doesn't offer the flexibility of 'style', although having a single definition of padding is convenient. Padding is defined in the 'wikitable' class:
 
<code><nowiki>
.wikitable th, .wikitable td {
border-top-color: #aaaaaa;
border-left-color: #aaaaaa;
border-right-color: #aaaaaa;
border-bottom-color: #aaaaaa;
border-top-width: 1px;
border-left-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-top-style: solid;
border-left-style: solid;
border-right-style: solid;
border-bottom-style: solid;
padding-top: 0.2em;
padding-right: 0.2em;
padding-bottom: 0.2em;
padding-left: 0.2em;
}
</nowiki></code>
 
Since that applies to each cell, it overrides the value "inherited" from a cellpadding attribute in the table element. The best I can suggest is to either apply <code>style="padding: 0.2em 0.8em;"</code> to each cell that requires padding, or to apply it to each row if you want it throughout the table. Example on a 'per-cell' basis:
 
{|class="wikitable" border="1"
|+ List of albums
! scope="col" rowspan="2" | Title
! scope="col" rowspan="2" | Album details
! scope="col" colspan="10"| Peak chart positions
! scope="col" rowspan="2" | Sales
! scope="col" rowspan="2" | [[List of music recording certifications|Certifications]]
|-
! scope="col" style="width:2em;font-size:75%"| [[Billboard 200|US]]
! scope="col" style="width:2em;font-size:75%"| [[ARIA Charts|AUS]]
! scope="col" style="width:2em;font-size:75%"| [[Austria|AUT]]
! scope="col" style="width:2em;font-size:75%"| [[Finland|FIN]]
! scope="col" style="width:2em;font-size:75%"| [[Netherlands|NLD]]
! scope="col" style="width:2em;font-size:75%"| [[New Zealand|NZ]]
! scope="col" style="width:2em;font-size:75%"| [[Norway|NOR]]
! scope="col" style="width:2em;font-size:75%"| [[Sweden|SWE]]
! scope="col" style="width:2em;font-size:75%"| [[Switzerland|SWI]]
! scope="col" style="width:2em;font-size:75%"| [[UK Albums Chart|UK]]
|-
! scope="row" | ''[[Bleach (album)|Bleach]]''
| style="padding: 0.2em 0.8em;" |{{Unbulleted list
|Released: June 15, 1989
|Label: [[Sub Pop]] <small>(SP #34)</small>
|Format: [[Compact disc|CD]], [[Compact cassette|cassette]], [[LP album|LP]]
}}
|style="text-align:center"| 89
|style="text-align:center"| 34
|style="text-align:center"| 26
|style="text-align:center"| 24
|style="text-align:center"| —
|style="text-align:center"| 30
|style="text-align:center"| —
|style="text-align:center"| —
|style="text-align:center"| —
|style="text-align:center"| 33
| style="padding: 0.2em 0.8em;" |{{nowrap|1.7 million (US)}}
| style="padding: 0.2em 0.8em;" |{{nowrap|Platinum (US)}}
|-
! scope="row" style="padding: 0.2em 0.8em;"| ''[[Nevermind]]''
| style="padding: 0.2em 0.8em;" |{{Unbulleted list
|Released: September 24, 1991
|Label: [[DGC Records|DGC]] <small>(DGC #24425)</small>
|Format: CD, CS, LP
}}
|style="text-align:center"| 1
|style="text-align:center"| 2
|style="text-align:center"| 2
|style="text-align:center"| 1
|style="text-align:center"| 5
|style="text-align:center"| 2
|style="text-align:center"| 2
|style="text-align:center"| 1
|style="text-align:center"| 2
|style="text-align:center"| 7
|style="padding: 0.2em 0.8em;" |{{Unbulleted list
|{{nowrap|10 million (US)}}
|{{nowrap|26 million (worldwide)}}
}}
|style="padding: 0.2em 0.8em;" |{{Unbulleted list
|{{nowrap|Diamond (US)}}
|{{nowrap|2× Platinum (UK)}}
}}
|}
 
The style="text-align:center" (''not align=center !!'') for the number cells may still be needed if we have cells in the column with different amounts of information in them. Otherwise, for example, '1' would line up left-aligned below '89' which looks horrible. Semantically, it's now fine (look at the page source), although it does seem a lot of effort just to make it look pretty. --[[User:RexxS|RexxS]] ([[User talk:RexxS|talk]]) 19:37, 12 September 2010 (UTC)
 
== Avoiding more than two levels of headers ==