Log in

View Full Version : question on tables



spyder
05-30-2005, 05:55 PM
i am making a table, and when i do width="100%" it leaves a 20px margin on the right

spyder
05-30-2005, 06:06 PM
here is the table thing


<table border="1" width="100%" height="150px" style="position:absolute;top:0px;left:0px" bgcolor="white" cellpadding="0px">

mwinter
05-30-2005, 06:44 PM
User agents typically add a margin or padding to the body element of a document. This spacing isn't considered in the 100% calculation.

The typical solution is to remove this spacing by way of CSS:


body {
margin: 0;
padding: 0;
}The table will now span the entire width. Just remember that other elements will now be flush against the viewport edges, so you may need to add a margin to them.

The start tag for your table element can now be simplifies somewhat to:


<table border="1" width="100%" height="150" bgcolor="white" cellpadding="0">Notice that I omitted the units in the height and cellpadding attributes. Unlike in CSS, HTML attributes assume pixels and never require units. However, almost all presentational units have been deprecated from HTML 4 in favour of style sheets.

Mike

spyder
05-30-2005, 06:57 PM
thank you very much. it works