George and Susan Welcome to our HTML help page!
Home | HTML-Index | Basic HTML | HTML Structure

Aling Data In A Table



ALIGN Data
Use the ALIGN attribute to change the horizontal alignment of data. By default the data in header cells (<TH>) is centered and the data in data cells (<TD>) is left aligned.

Example of default and right alignment.

Type this:
down
<TABLE BORDER=10 WIDTH="75%" ALIGN=CENTER>
<TR>
          <TH>The Table Header tag by default is bold and centered.</TH>
</TR>
<TR>
          <TD>This is a table data cell tag by default aligned left. </TD>
</TR>
<TR>
          <TD ALIGN=RIGHT>This text is aligned right.</TD>
</TR>
</TABLE>

And you get the following:
down
The Table Header tag by default is bold and centered.
This is a table data cell tag by default aligned left.
This text is aligned right.



Click in the tag of the cell ( <TH> or <TD> ), row ( <TR> ), column group ( <COLGROUP> or <COL> ) in row group ( <THEAD> , <TBODY> or <TFOOT> ) that contains the data you want to align horizontally.
Type in ALIGN=? replacing ? with the way you want to align the data ( LEFT , CENTER OR RIGHT ).
For more information on Column Groups  Click Here
For more information on Column Row Groups  Click Here




VALIGN

Type this:
down
<TABLE BORDER=10 WIDTH="75%" ALIGN=CENTER>
<TR VALIGN=TOP>
          <TH ROWSPAN=3>George's Products</TH>
          <TH>Product Name</TH>
          <TH>Price per unit</TH>
          <TH>Units Available</TH>
</TR>
<TR>
          <TD>Art Print</TD>
          <TD>$9.99</TD>
          <TD>40</TD>
</TR>
<TR>
          <TD>Books</TD>
          <TD>$3.99</TD>
          <TD>75</TD>
</TR>
</TABLE>

Type in VALIGN=? replacing ? with the way you want to align the data ( TOP , MIDDLE OR BOTTOM ).

And you get the following:
down
George's Products Product Name Price per unit Units Available
Art Print $9.99 40
Books $3.99 75

If you add cell padding to your table, the cell padding will affect the alignment of data, for more information on cell padding  CELLSPACING & CELLPADDING




My home page
Back to Top