Last modified: 2011-03-13 18:06:43 UTC
I can align a wiki table cell with align = "center" |, but "justify" does not work. HTML tables with justify work perfectly. Bug or feature?
Using wikisyntax, we can use align="justify" the html generated include it. The real problem is that "justify" is not valid for attribute align: From the HTML4 specification: http://www.w3.org/TR/html4/struct/tables.html#h-11.2.1 align = left|center|right [CI] Deprecated. This attribute specifies the position of the table with respect to the document. Permitted values: * left: The table is to the left of the document. * center: The table is to the center of the document. * right: The table is to the right of the document. The transitional XHTML 1.0 DTD tell us that element table accept the "align" attributed which can take a %TAlign value: <!ENTITY % TAlign "(left|center|right)"> Closing as invalid, as table can't have align="justify"
I was talking about *cell* alignment, not table alignment. http://www.w3.org/TR/html4/struct/tables.html#alignment align = left|center|right|justify|char
This is not a problem of MediaWiki. It is a problem of Internet Explorer 6.0. Firefox displays the table correct. I made a pure html page with table cell justifiy and it does not display right in IE 6.0.
For the curious: Try this with IE and Firefox: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> <title>Table justified</title> </head> <body> <table style="position: relative;" align="center" border="1" cellspacing="0" width="80%"> <tbody> <tr> <td align="left"><b>align left:</b> This is a very long text that does not fit in one line of the cell. Thisisaverylongtextthat doesnotfitinonelineofthecell. Thisisaverylongtextthat doesnotfitinonelineofthecell. Thisisaverylongtextthat doesnotfitinonelineofthecell. Thisisaverylongtextthat doesnotfitinonelineofthecell. Thisisaverylongtextthat doesnotfitinonelineofthecell. Thisisaverylongtextthat doesnotfitinonelineofthecell. Thisisaverylongtextthat doesnotfitinonelineofthecell. <br> new line </td> <td align="right"><b>align right:</b> This is a very long text that does not fit in one line of the cell. Thisisaverylongtextthat doesnotfitinonelineofthecell. Thisisaverylongtextthat doesnotfitinonelineofthecell. Thisisaverylongtextthat doesnotfitinonelineofthecell. Thisisaverylongtextthat doesnotfitinonelineofthecell. Thisisaverylongtextthat doesnotfitinonelineofthecell. Thisisaverylongtextthat doesnotfitinonelineofthecell. Thisisaverylongtextthat doesnotfitinonelineofthecell. <br> new line </td> </tr> <tr> <td align="middle"><b>align center:</b> This is a very long text that does not fit in one line of the cell. Thisisaverylongtextthat doesnotfitinonelineofthecell. Thisisaverylongtextthat doesnotfitinonelineofthecell. Thisisaverylongtextthat doesnotfitinonelineofthecell. Thisisaverylongtextthat doesnotfitinonelineofthecell. Thisisaverylongtextthat doesnotfitinonelineofthecell. Thisisaverylongtextthat doesnotfitinonelineofthecell. Thisisaverylongtextthat doesnotfitinonelineofthecell. <br> new line </td> <td align="justify"><b>align justify:</b> This is a very long text that does not fit in one line of the cell. Thisisaverylongtextthat doesnotfitinonelineofthecell. Thisisaverylongtextthat doesnotfitinonelineofthecell. Thisisaverylongtextthat doesnotfitinonelineofthecell. Thisisaverylongtextthat doesnotfitinonelineofthecell. Thisisaverylongtextthat doesnotfitinonelineofthecell. Thisisaverylongtextthat doesnotfitinonelineofthecell. Thisisaverylongtextthat doesnotfitinonelineofthecell. <br> new line </td> </tr> </tbody> </table> </body> </html>
Oh, there may be a solution to this. The parser.php may look for the justify tag... Display Justified Text in HTML Table Cell in IE To display justified text in a table cell, use the <p> HTML tag within the <td> tag with the attribute align set to "justify." So, instead of using: <td align="style="justify">Your text here.</td> Use this: <td><p align="justify">Your text here.</p></td> Ashish Mathur
The parser could be changed to make it work: // Bug 553: Note that a '|' inside an invalid link should not // be mistaken as delimiting cell parameters if ( strpos( $cell_data[0], '[[' ) !== false ) { $cell = "{$previous}<{$last_tag}>{$cell}"; } else if ( count ( $cell_data ) == 1 ) $cell = "{$previous}<{$last_tag}>{$cell_data[0]}"; else { $attributes = $this->mStripState->unstripBoth( $cell_data[0] ); $attributes = Sanitizer::fixTagAttributes( $attributes , $last_tag ); + // IE6.0 bug with justify cell + // justify has to be put into an additonal paragraph + $justifyPos = stripos($attributes,'justify'); + if ($justifyPos) $cell_data[1] = '<p align = \'justify\'>' . $cell_data[1] . '</p>'; $cell = "{$previous}<{$last_tag}{$attributes}>{$cell_data[1]}"; }
Ugly, and problematic due to the restrictions on the contents of <p> tags. Plus, un-semantic in general. If someone wants their justification to work in IE, they'll have to add the <p> tags themselves if they want them.