Help talk:Tables

From MediaWiki.org
Jump to: navigation, search

Let's keep it simple at the top and add tricks in extra sections down the page. Cheers :-) --Rogerhc 07:07, 4 September 2006 (UTC)

Contents

Page layout[edit]

The Help:Tables page is laid out as follows:

  • Under each heading is a 2 column parent table with the example table nested into its right column and the example's wiki markup in pre tags in the left column.
  • The parent table is width="100%" and the two columns containing the nested tables are each width="50%". Pre tags do not line wrap so please keep the example wikitext lines short within the pre tags, so that the presentation does not get messed up.
  • None of the page's sectional headings, H1, H2, H3, etc. are within tables, except the one in the example of how to do that. This keeps the sections easier to edit.

(Updated above text) --Rogerhc (talk) 06:19, 15 December 2012 (UTC)

Headings in tables[edit]

Of course, you can use headings within tables. Your above note on "MediaWiki not supporting this" is wrong. --:Bdk: 11:11, 4 September 2006 (UTC)

Thank you. I have now added a section on Tables with H1, H2, H3 etc. headings. :-) Rogerhc 04:45, 5 September 2006 (UTC)

When using attributes on headings, you must be aware that, although the header starts with an exclamation mark '!', the attributes parameter is still divided by a vertical bar '|'.

Example:

Heading
tekst

It took me a while to find out why my table was not formatting correctly, until I found the reas, as described here. All worth a change I made in the main HELP page, section 'Basics>Table Headers'. JanEnEm 07:39, 18 July 2011 (UTC)

Tables in Excel (/Calc) converted to Wiki Markup[edit]

Is there any software available to convert an "Microsoft Excel" or "Open-Office Calc" table into a MediaWiki markup text document?

File:Excel2MediaWiki.xlsm
Excel2MediaWiki

Would this be something people would consider usefull, as if it doesn't already exist, and there is a demand, I could a quick, basic one, as I use quite a few tables in my wiki.--Barryred

Yes! This would be absolutely helpful! --Nino Gonzales 04:10, 26 January 2007 (UTC)
See m:User talk:DBP.--Patrick 08:57, 26 January 2007 (UTC)

I've not tried this as I'm not a Python man but it might help. http://just-tech.blogspot.com/2007/01/python-html-tables-to-mediawiki.html --Dopple 09:27, 18 October 2007 (UTC)

On internet, several converters exists, one is excel2wiki.net

If there was a way for an extension to dynamically create and update an embedded excel (htm) file every time a wiki page loads or every time the excel base file was updated, that would be the coolest thing ever.

couple of conversion methods[edit]

With a newer OpenOffice (I have 3.2 on ubuntu 10.04), one can:

  • Open a new (Calc) spreadsheet, design your table
  • Select your table cells, copy
  • Open a new (Writer) text document
  • 'Paste Special' the copied Calc table cells as "HTML (HyperText Markup Language)" ["Formatted text (RTF)" does not seem to preserve formatting like color] in Writer

At this point, one can directly export this table in Writer via File/Export - and choosing 'MediaWiki (txt)' as 'File type' (note that Calc does not have a 'Mediawiki export'; however, Writer does.)

  • Note, however, that this export seems to be buggy, in respect to not recognizing rowspan cells (although, it seems to work with colspan cells correctly).

A better way for me, was to install wikEd (via Wikipedia:Tools/Editing tools); I installed it as a Greasemonkey script in Firefox.

  • Then, you can copy the html table from Writer, and paste it in a wikEd editor - formatting should be visibly preserved...
  • However, to actually convert it into Mediawiki markup, remember that: "If you want to keep a certain formatting, a link, or a table, you can convert the formatted pasted text into wiki code by pushing the wikify button [w]" (from wikEd_help#Converting_to_wiki_code)
  • This method - through wikEd - seems to not have a problem neither with rowspan, nor colspan cells - nor font color..

Cellpadding doesn't work[edit]

Old discussion deleted since this issue was fixed

...but thanks to Splarka for figuring out where the problem was in the CSS and Bdk for fixing it. -- Harry Wood 12:10, 4 January 2008 (UTC)


CSS style background-image not working inside cell style[edit]

Inside a cell the style parameter seems not to accept the parenthesis in background-image:url(/path/to/image.png);. See sample code:

{| border="1" 
| style="background-image:url(head.jpg); width:300px;" | fooo...
| style="width:100px;" align="right" | working style
|}

Here is the table:

fooo... working style

I tried using a template (like the {{!}}) and tried using ( and ). Do I see/do something wrong? How could I solve this? Didn't find anything in the docs or discussions yet...

- 80.254.136.33 - 11:19, 14 February 2008

Yeah most CSS within the style attribute should work ok, but I think any mention of 'url' is forbidden. So you can't use background images.
I could be wrong about that, but style attribute checking happens in includes/Sanitizer.php in the checkCSS function, and the comments there mention that urls are forbidden.
Probably the reason is to prevent certain kinds of minor security issues, people trying malicious CSS tricks. There is a setting Manual:$wgAllowExternalImages which malicious users might try to devise a workaround for, using style urls like this.
-- Harry Wood 14:28, 14 February 2008 (UTC)
There is a CSS way to fake this, by adding the cell content to a DIV and position it relative to the entire height or width of the image back. I cannot workout the cell-height entirely though.
-- Kokkan 01:59 September 19 2010 (CET)
{| border="1"
   ||[[File:information.png]]<div style="position: relative; left: 0px; top: -256px; height: 100px; ">fooo... </div>
  | style="width:100px;" align="right" | working style
  |}
Information.png
fooo... Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus
working style
You can even add a class to ...?title=Mediawiki:common.css and include the class to the tabel cell

add to common.css, where the path can be path to an uploaded file inside the wiki itself:

.MYBACKGROUNDCLASSNAME{
background-image: url(http://MYPATHTO/MYBACKGROUND.png);
 }

You can use more css to format the behavior of the pic. f.e. repeat: norepeat; ...

insert to table cell:

class="MYBACKGROUNDCLASSNAME"
I don't use this wiki, however, I wish to say this to whoever designed this beautiful, ingenious piece of code: thank you, thank you, thank you. 59.167.155.3 09:20, 5 June 2012 (UTC)

FWIW, I think the previous formatting was easier to read[edit]

This is better: http://www.mediawiki.org/w/index.php?title=Help:Tables&oldid=234654

The <pre> foo </pre> content inside of a bordered table is redundant...why use a box in a box?

Why not use foo (via <tt> foo </tt>) instead?

Applicationswhisperer 18:45, 17 February 2009 (UTC)

I just tried to make it a little more consistent with other help pages, such as Help:Images and Help:Formatting. --Aotake 22:00, 17 February 2009 (UTC)

Rowspan[edit]

Mention rowspan. People will be wondering if it is implemented or not. Best to not leave them guessing. Jidanni 04:15, 26 April 2009 (UTC)

Table Footer?[edit]

I noticed that ! denotes a table header, but there doesn't seem to be a tag/indicator for a table footer

There isn't one. 'Bang' (!) corresponds to HTML's <th> (table header) tag. Pipe (|) corresponds to HTML's <td> (table data) tag. HTML does not have a 'table footer' tag. - Turing 07:26, 3 September 2009 (UTC)

HTML 5[edit]

See also W:MediaWiki_talk:Common.css#Wikitable borders disappear in email, blogs, disks, mobile devices. Jidanni 18:42, 19 August 2009 (UTC)

Borderless table[edit]

Hello everyone, I was wondering if anyone could tell me (or show me) how to make a borderless table, not one with a white border but with no border at all, thanks. Supaman89 (talk) 23:12, 6 October 2009 (UTC)

Answer:

{| border="0" 
|colspan="2" bgcolor="blue"|explicit
|-
|bgcolor="red"|borderless
|bgcolor="green"|table
|}

Here is the table:

explicit
borderless table

or

{|
|colspan="2" bgcolor="blue"|implicit
|-
|bgcolor="red"|borderless
|bgcolor="green"|table
|}

Here is the table:

implicit
borderless table

Try this:

{| style="border-spacing: 0px;"
|colspan="2" bgcolor="blue"|implicit
|-
|bgcolor="red"|borderless
|bgcolor="green"|table
|}
implicit
borderless table

--Ayvengo21 09:28, 12 May 2010 (UTC)

Table Height[edit]

Hey, is there a way to specify a height cell- or table-wise? Bud0011 21:12, 25 September 2010 (UTC).


It can be specified cell-wise:

a
b

Hamilton Abreu 23:53, 25 September 2010 (UTC)

Sweet, thank you. On a side note, do you know much about hooks? Bud0011 14:20, 26 September 2010 (UTC).
Nope, try Project:Support desk. Hamilton Abreu 16:10, 26 September 2010 (UTC)
Ok. Thank you. Bud0011 16:33, 26 September 2010 (UTC).

No text next to table[edit]

I have a table on a page:
{| border = "1" align="left" style="width:100%; background-color:#FFFFCC; color:black" | none !style="color: blue; font-style:italic"| Poort # |}
Trouble is the next header gets placed on the right side of the table and now I have to add a lot of br's. How do make up the table so no text is allowed on either side of it?

TIA!

Please elaborate on your problem. Examples of what i think you mean are in the collapsed table bellow
  1. If you want no text in the next cell to the right, then placing no next cell to the right would help with that (Example #1).
  2. If you are looking to clear both the sides of the table, <div style="clear:both;"> could help clear the text, like Example 2 bellow.
  3. Example #3 uses margins to push the outside text away from the
Hope this helps. Bud0011 15:56, 17 January 2011 (UTC).

Tables messed up in theme change[edit]

When I changed the customizable page color (for the background), it messed up the wikitables, making the borders a different color and making the backgrounds match. While the matching/transparent background is fine, is there a way to make the borders stay the default black? NeocarleenTalk 01:36, 17 February 2011 (UTC)

umm, did you try changing the border color? 58.11.147.228

Mutliple Tables - Padding[edit]

  • I have a Template that builds a table using the Wiki syntax but when it is shown, instead of each table being on top of each other, there seems to be a natural "padding" or "margin" between the tables. Roughly 15 to 25px buffer between the tables. Anyone know how i can get rid of this? Example: http://batheo.wikia.com/wiki/Quests/Attack#Rewards
  • Thanx in advance, Goldbishop 20:30, 2 March 2011 (UTC)

Table Restarts number Sequence[edit]

Hello people, say does anyone know how to use a table in a number sequence and not have the table restart it? I'll show you what I mean if I didn't make that clear:

  1. test
  2. test
  3. test
Documentation Required: other
  1. See how the numbers start over at One here.
  2. How do I fix this???

March 8th 10:13am CST 2011


Table needs NewLine, which stops sequences. One solution is to manually start again the list with fixed number, using the ol and li codes:


  1. test
  2. test
  3. test
Documentation Required: other
  1. See, the numbers don't start over at One here.
  2. This is a possible fix
  3. But you have to manually fix the starting number to 4

Align not working?[edit]

I've noticed that the align used in tables does not work anymore, even on older mediawiki versions? Any explanations?

See https://bugzilla.wikimedia.org/show_bug.cgi?id=36495 Cursich (talk) 22:38, 22 February 2013 (UTC)

Different text-align for different columns[edit]

How do I set up the wikitables so that the first column is align:left and the last column is align:right?

Advanced Layout[edit]

Can anyone advise on the best way to create the following layout, I'm creating a table with an Icon, then 8 pieces of data to the right of that, then another icon and 8 pieces of data adjacent.

This is my code;

| rowspan="8" valign="top" width="120" | [[File:Information.png|]]
! colspan="2" align="left" | <font face="Arial Black" size="5" style="text-transform: uppercase;"> Heading A </font>
| rowspan="8" valign="top" align="center" width="150" | [[File:Example.jpg|]]
! colspan="2" align="left" | <font face="Arial Black" size="5" style="text-transform: uppercase;"> Heading B </font>
|-
! align="left" | Item A Detail 1:
| Item A Info 1
! align="left" | Item B Detail 1: 
| Item B Info 1
|-
! align="left" | Item A Detail 2:
| Item A Info 2
! align="left" | Item B Detail 2: 
| Item B Info 2
|-
! align="left" | Item A Detail 3:
| Item A Info 3
! align="left" | Item B Detail 3: 
| Item B Info 3
|-
! align="left" | Item A Detail 4:
| Item A Info 4
! align="left" | Item B Detail 4: 
| Item B Info 4
|-
!
|
! align="left" | Item B Detail 5:
| Item B Info 5
|-
!
|
! align="left" | Item B Detail 6: 
| Item B Info 6
|-
!
|
! 
| 
|-

Result:

Information.png Heading A Example.jpg Heading B
Item A Detail 1: Item A Info 1 Item B Detail 1: Item B Info 1
Item A Detail 2: Item A Info 2 Item B Detail 2: Item B Info 2
Item A Detail 3: Item A Info 3 Item B Detail 3: Item B Info 3
Item A Detail 4: Item A Info 4 Item B Detail 4: Item B Info 4
Item B Detail 5: Item B Info 5
Item B Detail 6: Item B Info 6

This is repeated down the page to allow for several levels of icons and their respective data, Nested templates sounds like a cleaner way to present this, however I've heard nested templates are a bad way to go from an SEO perspective, however the alternative means data in the wiki syntax is non sequential, So I'm jumping from Item A to Item B, which can't be good practise and mess up SEO?

Is there a better way to do this kind of layout, that is cleaner and will not affect SEO?

Repeating headers[edit]

In a large table, it might be user-friendly to repeat the header every 20 or ? rows. Might it be possible to add an option to the header that tells mediawiki to repeat the header automatically?


Simple one-pixel table border[edit]

I don't understand what this section is about. It may be better moved to a Help:Advanced Tables page. I will leave it in the Help:Tables page for now. But someone may want to remove it. Really, how does it help folks? Who is going to want all that cruft in their wiki markup? --Rogerhc (talk) 06:08, 15 December 2012 (UTC)

Fixed your grammar mistake. 58.11.147.228 00:06, 8 May 2013 (UTC)

Text is overriding row height even if the font is small[edit]

I tried pixels and percentages and it only works if the entire row is empty, even if I set the font size with the html font tag to somethign really small, it doesn't work. How can I edit the actual classes for my wiki?--88.104.102.18 12:42, 2 April 2013 (UTC)

It seems I can only make the row height bigger, not smaller, small font sizes still do not work, I have tiny text surrounded by pointless space.

Table centering?[edit]

How to center tables in the middle of a page? 58.11.147.228 00:04, 8 May 2013 (UTC)