How do I adjust column widths in a table?

+6 votes
200 views
I am trying to set the column widths for my table so that the width is not determined by the content. I used the code below which I found in other posts but no matter what size I make the columns there is no change in the column width. Any help would be greatly appreciated.

{| border="3"  style="text-align:center" bgcolor="#f5f5f5"
|+ Name of Table
! scope="col" style="width: 100pt;" | SAR Patriot #
! scope="col" style="width: 75pt;" | Indicators
|
WikiTree profile: Space:Campbell_SAR_Patriots
in WikiTree Help by Kevin Guy Campbell G2G6 (6.7k points)

1 Answer

+8 votes

What you have seems close to working. I modified it to this which worked:

{| border="3"  style="text-align:center" bgcolor="#f5f5f5"
|+ Name of Table
! scope="col" style="width: 100pt;" | SAR Patriot #
!! scope="col" style="width: 75pt;" | Indicators
!! scope="col" style="width: 200pt;" | Wide
|-
| num || ind || long text
|}

However - be aware that WikiTree does not want people to use the style="" in tables because it goes against WikiTree guidelines of embedding CSS style statements in biography text. See this help page.

by Rob Pavey G2G6 Pilot (211k points)
Here is a simplified version that also works that doesn't break the WikiTree rules:

{| border="3"  style="text-align:center" bgcolor="#f5f5f5"
|+ Name of Table
! width=100pt | SAR Patriot #
!! width=75pt | Indicators
!! width=200pt | Wide
|-
| num || ind || long text
|}
Note that it will still increase the width to fit the longest word in the content. So if you want a really narrow table it needs have short words. E.g:

{| border="3"  style="text-align:center" bgcolor="#f5f5f5"
|+ Name of Table
! width=100pt | SAR Patriot #
!! width=5pt | I n d i c a t o r s
!! width=200pt | Wide
|-
| num || ind || long text
|}
Rob, thanks for that. I tested this and it works. Yahoo!
My table has 11 columns and it seems like I would have to identify the kind of characters that will be in the field. Is that correct and is there a help page that will show the different kind of charcters in a field.

I will eliminate the CSS style=, if there is a way do this with Wiki Markup. So if you could recommend that as well it would be appreciated.

I'm not sure what you mean by "the different kind of characters in a field"

FYI if you just want to make your tables all the same width you can tell it to fit the whole table to the width of the page. Like this:

{| border="1" width="100%"
|- bgcolor=#E1F0B4
| Name || Relation || Status || Sex || Age || Occupation || Birth Place
|-
| Harry A Pavey || Head || Married || M || 38 || Picture frame maker || Plymouth, Devon, England
|}

Rob, it looks like you simply added 
|-
| num || ind || long text

for the columns. What is "num", "ind", "long text" that you added? I was thinking it was for the type of characters that were going to be in the column.

No that was just sample content :)
FYI there is an online tool that will convert a spreadsheet into a wiki table. I haven't tried it: https://magnustools.toolforge.org/tab2wiki.php

And this tool converts an HTML table to a WikiTable: http://bmanolov.free.fr/html2wiki-tables.php

Here is more documentation on Wiki Tables: https://www.mediawiki.org/wiki/Help:Tables

Related questions

+4 votes
1 answer
+7 votes
0 answers
248 views asked Sep 3, 2023 in The Tree House by Kay Knight G2G6 Pilot (605k points)
+7 votes
1 answer
+9 votes
4 answers
+4 votes
1 answer
+4 votes
1 answer
194 views asked Aug 18, 2020 in WikiTree Tech by Amber Brosius G2G6 Mach 2 (25.4k points)
+7 votes
3 answers
285 views asked Nov 20, 2018 in WikiTree Help by Jean Price G2G6 Mach 5 (53.5k points)
+6 votes
2 answers
+4 votes
1 answer
+15 votes
3 answers
676 views asked Jun 28, 2014 in WikiTree Tech by Jillaine Smith G2G6 Pilot (914k points)

WikiTree  ~  About  ~  Help Help  ~  Search Person Search  ~  Surname:

disclaimer - terms - copyright

...