Tables are perhaps the only tricky part of HTML. Following are some things to understand:
1. To begin working on a table, you must first introduce a <table> tag in to your code to specify the beginning of your table code.
2. Tables borders can be defined and they can be aligned by using the <align=”center/left/right “> tag.
3. Each table has two components: <tr> tag defines the table rows and the <td> tag defines the data cells.
4. A table can have various attributes.
Following is the html code tutorial for a basic table having 3 rows and 3 cells (columns).
– Html table tutorial –
<html><body>
<table border=”1″>
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
<td>row 1, cell 3</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
<td>row 2, cell 3</td>
</tr>
<tr>
<td>row 3, cell 1</td>
<td>row 3, cell 2</td>
<td>row 3, cell 3</td>
</table>
</body></html>
Note: If you replace the <table border> tag with just plain <table>, you will get a table without any borders.
The next example aligns a basic 2 rows and 2 cells table to the center, but you can change the attribute by replacing “center” with “left” or right”. I’m also inserting some headings to help you understand the <th> tag.
<html><body>
<table border=”1″, align=”center”>
<tr>
<th>heading 1</th>
<th>heading 2</th>
</tr>
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
</body></html>
HTML Tables:
February 18th, 2008 · No Comments
Tags: HTML tutorials
0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.
You must log in to post a comment.