MMDT1021 Chapter 14 Notes - page 3

Centering a Table on a Page

Code Page
<table border="1" align="center"> Result
Source

 Wrapping Text Around a Table

Code Page
<table border="1" align="left"> Result
Source

Adding Space Around a Table

This only works in Netscape.
Code Page
<table border="1" hspace="50" vspace="50"> Result
Source
 

 Spanning a Cell across Columns

Code Result
<table border="1">
  <tr>
    <td colspan="2">column 1 row 1</td>
  </tr>
  <tr>
    <td>column 1 row 2</td>
    <td>column 2 row 2</td>
  </tr>
</table>
 
column 1 row 1
column 1 row 2 column 2 row 2
 

 Spanning a Cell across Rows

Code Result
<table border="1">
  <tr>
    <td rowspan="2">column 1 row 1</td>
    <td>column 2 row 1</td>
  </tr>
  <tr>
    <td>column 2 row 2</td>
  </tr>
</table>
 
column 1 row 1 column 2 row 1
column 2 row 2
 

Aligning a Cell's Contents

Left.
Code Result
<table border="1" width="300">
  <tr>
    <td align="left">column 1 row 1</td>
    <td align="left">column 1 row 2</td>
  </tr>
  <tr>
    <td align="left">column 1 row 2</td>
    <td align="left">column 2 row 2</td>
  </tr>
</table>
 
column 1 row 1 column 2 row 1
column 1 row 2 column 2 row 2
 
Center.
Code Result
<table border="1" width="300">
  <tr>
    <td align="center">column 1 row 1</td>
    <td align="center">column 1 row 2</td>
  </tr>
  <tr>
    <td align="center">column 1 row 2</td>
    <td align="center">column 2 row 2</td>
  </tr>
</table>
 
column 1 row 1 column 2 row 1
column 1 row 2 column 2 row 2
 
Right.
Code Result
<table border="1" width="300">
  <tr>
    <td align="right">column 1 row 1</td>
    <td align="right">column 1 row 2</td>
  </tr>
  <tr>
    <td align="right">column 1 row 2</td>
    <td align="right">column 2 row 2</td>
  </tr>
</table>
 
column 1 row 1 column 2 row 1
column 1 row 2 column 2 row 2