Software Sue

Link to Simply Sue
Link to Sustainability Sue
location: software/markup/html/tables/alignment, width, height Skip navigation : Home  

HTML table alignment, width, height


alignment, width, height


Note. These pages have not been upgraded from HTML to XHTML


View source to see the code






Alignment


To have more than one line in a cell, use <BR>. You can align single cells or whole rows to the right, left or centre using align=LEFT|RIGHT|CENTER, and to the top, middle or bottom using Valign=TOP|BOTTOM|MIDDLE. You can add a caption to the top or bottom of a table using caption=TOP|BOTTOM.

This is a caption at the top. This is a caption at the bottom in IE, but not in NN.
Head1Head2Head3
1. This is an example2. Of multiple lines 3. In a cell. There is a break here
to force a second line.
4. All of5. this row6. is centre-aligned.
7. This cell is right-aligned. 8. This cell is left-aligned. 9. This is the default alignment.
10. Top. 11. Bottom. 12. Default (<br />)
alignment.

You can align a table on a page using <CENTER> and </CENTER>.

Width=50%Width=50%
IJ

Table and Cell Width

Percentage Width

You can specify the percentage of the width of the screen that a table will take up using the WIDTH attribute. For example:

Width=50%Width=50%
AB
Width=75%Width=75%
CD
Width=100%Width=100%
EF

The width of the data item in a cell can affect the cell size, however:

The width of the data item in a cell can affect the cell size, however.Width=100%
GH

You can use table width in nested tables:

Outer 1 - 75%Outer 2
Inner 1 - 50%Inner 2
Outer 3

If you specify the width of a table as a percentage, then the table will fill that percentage of the screen's width, and the user will not need to scroll. Use percentage if:

  • users may not size their browsers wide enough

Fixed width

You can also specify a fixed width for a table. If you specify the width of a table as a fixed number of pixels, the table should remain its width however the users resize their browser window. If they resize their window so that it is narrower than the table, however, they will need to scroll across to see it all. Used fixed width if:

  • you want a standard parameter for your site
  • you want to arrange some small graphics precisely.
The width of this table is:500 pixels
KL

Do not specify a table of width greater than 800 pixels if you don't want your users to have to scroll to see it all.

If you do not specify a table's width, the browser will use its own algorithm to select a width.

However you specify a table's width, each table has a minimum size, catering for the length of the longest single word or widest image in each cell.

Neither the size of the user's monitor nor its screen resolution has much effect on how tables display.

Examples of Web tables with varying widths can be found at The HTML Station.

Height

HEIGHT=10%Item 2
34

HEIGHT=20%Item 2
34

Note: In earlier versions, it was possible for the sum of the elements within a table cell to exceed the width specified in its tag, but in the latest version of Netscape Communicator, which has now accepted the World Wide Web Consortium's HTML standards, the elements will become misaligned.