HTML - simple table
Simple Table Code
<table> <thead> <tr> <th>heading col 1</th> <th>heading col 2</th> </tr> </thead> <tr> <td>row 1, column 1</td> <td>row 1, column 2</td> </tr> <tr> <td>row 2, column 1</td> <td>row 2, column 2</td> </tr> </table> | ||||||
This is how it will appear in a browser | ||||||
| ||||||
View above example output in a new browser window |
Table with border code
<table border="1"> <thead> <tr> <th>heading column 1</th> <th>heading column 2</th> </tr> </thead> <tr> <td>row 1, column 1</td> <td>row 1, column 2</td> </tr> <tr> <td>row 2, column 1</td> <td>row 2, column 2</td> </tr> </table> | ||||||
This is how it will appear in a browser | ||||||
| ||||||
View above example output in a new browser window |
table with cellpadding and cellspacing
<table border="1" cellpadding="4" cellspacing="6" > <thead> <tr> <th>heading column 1</th> <th>heading column 2</th> </tr> </thead> <tr> <td>row 1, column 1</td> <td>row 1, column 2</td> </tr> <tr> <td>row 2, column 1</td> <td>row 2, column 2</td> </tr> </table> | ||||||
This is how it will appear in a browser | ||||||
| ||||||
View above example output in a new browser window |
Table with background color
In XHTML 1.1 the attribute 'bgcolor' is not permitted for the <td> tag.
<table border="1" > <thead> <tr> <th>heading column 1</th> <th>heading column 2</th> </tr> </thead> <tr> <td bgcolor="yellow" >row 1, column 1</td> <td>row 1, column 2</td> </tr> <tr> <td>row 2, column 1</td> <td>row 2, column 2</td> </tr> </table> | ||||||
This is how it will appear in a browser | ||||||
| ||||||
View above example output in a new browser window |