Difference between revisions of "HTML table formatting"
(again) |
(GASP! I had to manually make the table look like a wikitable because if you just do the class then it messes up the tables that are inside this table = phew) |
||
| Line 39: | Line 39: | ||
This can also be combined with other elements to change styling. However this element is relatively restricted - as you are unable to efficiently change the color of the border, and alternatively you could present the border as a component of a style variable, however as you can see in the table below - this only works for the outside border. This border argument is presented with 3 sub-components - width, style (hidden, dotted, dashed, solid, double, groove, ridge, inset, outset) and color.<code><nowiki><table style="border: 1px solid blue"></nowiki></code> | This can also be combined with other elements to change styling. However this element is relatively restricted - as you are unable to efficiently change the color of the border, and alternatively you could present the border as a component of a style variable, however as you can see in the table below - this only works for the outside border. This border argument is presented with 3 sub-components - width, style (hidden, dotted, dashed, solid, double, groove, ridge, inset, outset) and color.<code><nowiki><table style="border: 1px solid blue"></nowiki></code> | ||
| − | {| | + | <!--For this table DO NOT use any classes - they screw up the tables that are inside of this - I've manually made the table essentially the class --> |
| − | !colspan=" | + | {| style="margin:1em 1em 1em 0; background:#F9F9F9; border:1px; border:1px #AAA solid; border-collapse:collapse" |
| + | !colspan="4" style=" border:1px #AAA solid; background:#F2F2F2;"|Various Tables and Borders<sup>[[#Note|[1]]]</sup> | ||
|- | |- | ||
| − | !Code | + | !style=" border:1px #AAA solid; background:#F2F2F2;"|Code |
| − | !Result | + | !style=" border:1px #AAA solid; background:#F2F2F2;"|Result |
| + | !style=" border:1px #AAA solid; background:#F2F2F2;"|Code | ||
| + | !style=" border:1px #AAA solid; background:#F2F2F2;"|Result | ||
|- | |- | ||
| − | |<code><nowiki><table border='3px'></nowiki></code> | + | |style="border-right:1px #AAA solid; border-bottom:1px #AAA solid;"|<code><nowiki><table border='3px'></nowiki></code> |
| − | |<table border= | + | |style="border-bottom:1px #AAA solid;"| |
| + | <table border="3px"> | ||
<TR><TD>blue</TD><TD>skies</TD><TR> | <TR><TD>blue</TD><TD>skies</TD><TR> | ||
<TR><TD>pink</TD><TD>hearts</TD><TR> | <TR><TD>pink</TD><TD>hearts</TD><TR> | ||
<TR><TD>green</TD><TD>clover</TD><TR> | <TR><TD>green</TD><TD>clover</TD><TR> | ||
</table> | </table> | ||
| − | |- | + | |style="border-right:1px #AAA solid; border-left:1px #AAA solid; border-bottom:1px #AAA solid;"|<code><nowiki><table frame=box rules=all border=2></nowiki></code> |
| − | | | + | |style="border-bottom:1px #AAA solid;"| |
| − | <code><nowiki><table frame=box rules=all border= | + | <table frame=box rules=all border=2> |
| − | | | ||
| − | <table frame=box rules=all border= | ||
<TR><TD>blue</TD><TD>skies</TD><TR> | <TR><TD>blue</TD><TD>skies</TD><TR> | ||
<TR><TD>pink</TD><TD>hearts</TD><TR> | <TR><TD>pink</TD><TD>hearts</TD><TR> | ||
| Line 61: | Line 63: | ||
</table> | </table> | ||
|- | |- | ||
| − | |<code><nowiki><table style="border: 1px solid blue"></nowiki></code> | + | |style="border-right:1px #AAA solid;"|<code><nowiki><table style="border: 1px solid blue"></nowiki></code> |
|<table style="border: 1px solid blue"> | |<table style="border: 1px solid blue"> | ||
| + | <TR><TD>blue</TD><TD>skies</TD><TR> | ||
| + | <TR><TD>pink</TD><TD>hearts</TD><TR> | ||
| + | <TR><TD>green</TD><TD>clover</TD><TR> | ||
| + | </table> | ||
| + | |style="border-right:1px #AAA solid; border-left:1px #AAA solid;"|<code><nowiki><</nowiki>table style="border-top:1px solid blue;<br/> border-bottom: 3px solid maroon; <br/>border-right:none; <br/>border-left: 1px double black"<nowiki>></nowiki> | ||
| + | |<table style="border-top: 1px solid blue; border-bottom: 3px solid maroon; border-right:none; border-left: 1px double black;"> | ||
<TR><TD>blue</TD><TD>skies</TD><TR> | <TR><TD>blue</TD><TD>skies</TD><TR> | ||
<TR><TD>pink</TD><TD>hearts</TD><TR> | <TR><TD>pink</TD><TD>hearts</TD><TR> | ||
Revision as of 13:58, August 23, 2007
HTML table formatting is cumbersome and often perplexing. For instance, to get rid of the hollow or "chiseled" borders between rows and columns, use these codes: frame=box rules=all
Syntax
Standard
Every table starts out with the ordinary tag <table>. This is typically followed by a <tr> tag which signifies the beginning of a new row. This is followed by a <td> tag which stands for "table data" - i.e. every box inside the row.
| <-- Each black item is a table data | ||
| <-- This blue item is the table row | ||
Colspan and Rowspan
Every row must have the same number of table datas, occasionally table datas have to span more than one column or row. In this case the tags colspan and/or rowspan are used - where they are set to a number.
| <-- This row has three table datas | |||
<-- This row has two. The first uses colspan="2"
| |||
<-- This row has three table datas, but one spans two rows because it uses rowspan="2"
| |||
| <-- This row has only two table datas, because its first is being taken up. | |||
Borders
Border can be done one of two ways. Typically the best way to do borders is having a border variable isolated - as in:
<TABLE border='3px'>
This can also be combined with other elements to change styling. However this element is relatively restricted - as you are unable to efficiently change the color of the border, and alternatively you could present the border as a component of a style variable, however as you can see in the table below - this only works for the outside border. This border argument is presented with 3 sub-components - width, style (hidden, dotted, dashed, solid, double, groove, ridge, inset, outset) and color.<table style="border: 1px solid blue">
| Various Tables and Borders[1] | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Code | Result | Code | Result | ||||||||||||
<table border='3px'>
|
|
<table frame=box rules=all border=2>
|
| ||||||||||||
<table style="border: 1px solid blue">
|
|
<table style="border-top:1px solid blue; |
| ||||||||||||
Note
[1]Borders can also more tediously be set for <td> and <th> tags.