Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Should be simple - table widths and cellspacing

Status
Not open for further replies.

Einstein47

Programmer
Nov 29, 2001
737
US
Okay - this should be easy, but maybe not. Do the attributes cellpadding and cellspacing (and border for that matter) add to the width of a table cell or are they subtracted from the set size.

Example - I have a table (simplified) as follows:
Code:
<TABLE border=&quot;0&quot; cellspacing=&quot;2&quot; cellpadding=&quot;2&quot;>
  <TR class=head>
    <TD width=200>Date / Time</TD>
  </TR>
</TABLE>
<TABLE border=&quot;0&quot; cellspacing=&quot;2&quot; cellpadding=&quot;2&quot;>
<% while (it.hasNext)
    { %>
  <TR>
    <TD width=100><%=it.date%></TD>
    <TD width=100><%=it.time%></TD>
  </TR>
<%  } %>
</TABLE>

You see my header is a separate table from my results set. I need to know if the 200 in the header is the same as the 2 cells of width 100 in the results. OR will the cellspacing and cellpadding cause the results widths to be wider than 200.

Is there an easy way to calculate table widths? AND is it standard between IE and Netscape (this is tables for heaven's sake, HTML 2 spec).


Anyone ?!?

Einstein47
(&quot;Vision without action is a daydream - Action without vision is a nightmare. Japanese Proverb&quot;)
 
they add to the dimensions, so if you want a table to be 200 pixels wide with a 2 pixel padding then your cells would be 196, if you want 1 pixel border then you are looking at 194 cells

[Hammer]
Nike Failed Slogans -- &quot;Just Don't Do It!&quot;
 
your TD width should be set as a percentage of the table width, then you don't have to worry about it...
example with 3 columes:
table width=200 (or 600 or 150 or 320, any width)
<TD width=20%>col 1</TD><TD width=40%>Col 2</TD><TD width=40%>Col 3</TD>
Total TD percentage must add up to 100%
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top