User:Timeshifter/Sandbox241

From Wikipedia, the free encyclopedia

Setting column widths. Other methods.

To force column widths to specific requirements, rather than accepting the width of the widest text element in a column's cells, follow this example. Note that wrap-around of text is forced.

Wikitext

{| class=wikitable
|-
! scope="col" style="width: 50px;" | Name
! scope="col" style="width: 250px;" | Effect
! scope="col" style="max-width: 300px;" | Games found in
|-
| Poké Ball || Regular Poké Ball || All versions
|-
| Great Ball || Better than a Poké Ball || All versions
|}

Produces

Name Effect Games found in
Poké Ball Regular Poké Ball All versions
Great Ball Better than a Poké Ball All versions

To set column widths in a table without headers, specify the width in the first cell for each column.

Wikitext

{| class=wikitable
|-
| style="width: 100pt;" | This column is 100 points wide
| style="width: 200pt;" | This column is 200 points wide
| style="width: 300pt;" | This column is 300 points wide
|-
| blah || blih || bluh
|}

Produces

This column is 100 points wide This column is 200 points wide This column is 300 points wide
blah blih bluh

You can also use percentages, such as to equalize the widths of a two-column table by setting one of them to style="width: 50%;".

One application of setting the widths is aligning columns of consecutive tables. The following are separate tables, with columns set to 350px and 225px.

Wikitext

{| class=wikitable
|-
! scope=col style="width: 350px;" | Country
! scope=col style="width: 225px;" | Capital
|-
| Netherlands || Amsterdam
|}

{| class=wikitable
|-
! scope=col style="width: 350px;" | Country
! scope=col style="width: 225px;" | Capital
|-
| France || Paris
|}

Produces

Country Capital
Netherlands Amsterdam
Country Capital
France Paris