Tables Basics Tutorial
Thank you for using our SharperMyspace tutorials! We are pleased to know that we have helped you in some way today. If you have any questions or concerns about our tutorials, please
contact us.
Tutorial
Table Basics
|
| Code | Description |
| Starts defining a table in HTML. |
|
| Starts a row within the table. You may use different attributes that will affect the entire row. ALIGN and VALIGN can be used. |
| | Starts a cell within a row. Cells can use different attributes to define what the text in them will look like and how they are aligned. They are aligned to the left and centerered vertically by default. |
| | Starts a header cell within a row. Header cells may also use different attributes to define what the text in them will look like and how they are aligned. The text is bold and centered by default. |
Table Attributes
|
| Attribute | Description |
| ALIGN (CENTER, LEFT, RIGHT) | Aligns the text horizontally. |
| VALIGN (MIDDLE, TOP, BOTTOM) | Aligns the text vertically. |
| NOWRAP | Turns off word wrap within the cell. (The text will go on and on and not go to a new line unless you do it manually. |
| ROWSPAN= | Changes the amount of rows the cell will span. |
| COLSPAN= | Changes the amount of columns the cell will span. |
| Note: Attributes assigned in <TD></TD> or <TH></TH> will override what is set in <TR></TR> |
Putting It All Together
To put it all together, we first have to start defining the table.
Now we have to start the first row.
Then we have to put in the first cell and second cell, with some text, then close the cell.
| A Cell | Another Cell |
Next we have to close the row the cells are in.
| A Cell | Another Cell |
Finally we have to close the table.
And here is what it would look like on an HTML page:
To add the border so you can see the actual cells, you would have to add border=1 to <table>, so it looks like this:
Example Table Code
When placed in an HTML document, this table looks like this: