5.1 The table Tag

tags,

tags, alignment, tables, alignment, tables, align attribute, tags, hspace attribute, tags, vspace attribute, tags, margins, table, vspace attribute, tags, size, table, width attribute, tags, size , table columns, columns , table, borders, table, border attribute, table tags, margins, table cells, borders, table cells , cellpadding attribute, , cellspacing attribute, , padding, alignment, table cell contents, valign attribute, tags">
Team-Fly    

 
Webmaster in a Nutshell, 3rd Edition
By Robert Eckstein, Stephen Spainhour
Table of Contents
Chapter 5.  Tables

5.1 The <table> Tag

Tables are normally treated as floating objects within a browser window. They're aligned in the browser window to match the text flow, usually left-justified (or centered). Unlike inline images, however, text normally floats above and below a table but not beside it. Internet Explorer and Netscape allow you to set the alignment of a table and float text around it with the align attribute. align accepts two values, left and right. These values instruct the browser to align the table with either the left or right margin of the text flow around it. Text then flows along the opposite side of the table, if there is room.

The hspace and vspace attributes add extra space between the table and surrounding content. hspace adds space to the left and right sides of the table; vspace adds space above and below it. The value of each attribute is given as an integer number of pixels.

The width attribute can give you some control over the width of a table. Tables are normally rendered at the width that fits all the contents. The width attribute allows you to widen the table beyond the default size to occupy a set number of pixels or a percentage of the window's width. For example:

 <table width="100%" > 

always stretches the table to the full width of the browser window. This is a conditional instruction, however. The size of a table cell is always determined by the size of the biggest "fixed" content, such as an image or a nonbreaking line of text. Therefore, a table may need to be wider than you wish it. If the table cells contain mostly wrapping text elements such as paragraphs (<p>), the browser usually accommodates your request.

The border attribute to <table> controls the borders within and around the table. Simply using border with no attributes adds default borders to a table, which are not rendered the same in any two browsers. You can set border width by giving the attribute an integer number of pixels as a value. The border=0 setting turns table borders off completely.

The amount of space around each cell is controlled by the cellpadding and cellspacing attributes to the <table> tag. Each accepts an integer number of pixels as a value. cellpadding sets the space between a cell's contents and its edges, whether borders are on or off. cellspacing sets the space between adjacent table cells. If borders are turned on, cellspacing will add the space outside of the border (half on one side, half on the other). The border width is not included or affected by cellspacing or cellpadding.

The additional attributes to the <table> tag are supported only by Internet Explorer. The rules and frames attributes tell the browser where to draw the rules (or borders) in the table. These settings depend on the use of other tags for the table such as <colgroup> or < tfoot >, which group table cells into distinct sections. There are many different values for rules and frames, making this feature quite versatile. It is, however, not supported in other browsers.

The other <table> attributes exclusive to Internet Explorer set backgrounds and colors for 3D borders. They are also usable in the lower-level <tr>, <th>, and <td> tags. They are discussed presently.


Team-Fly    
Top


Webmaster in a Nutshell
Webmaster in a Nutshell, Third Edition
ISBN: 0596003579
EAN: 2147483647
Year: 2002
Pages: 412

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net