473,405 Members | 2,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

TD WIDTH and CELLPADDING (full post)

Apologies for the partial post that mysteriously escaped as I was composing.
I shall try again.

For many years I have been happily and successfully coding tables such that
the WIDTH
specified in a TD is the complete column width including any CELLPADDING.
For example for a 400 pixel wide table with four 100 pixel wide columns and
10 pixel cellpadding...

<TABLE WIDTH="400" BORDER="0" CELLSPACING="0" CELLPADDING="10">
<TR>
<TD WIDTH="100">
<TD WIDTH="100">
<TD WIDTH="100">
<TD WIDTH="100">
</TR>
</TABLE>

This is, to me, intuitive and is clearly how many others think it should be
done too judging by tutorials on the net and actual coding used. However
while using GoLive 6.01 (and this is not something I noticed with earlier
versions) I noticed that it considers that the WIDTH only covers the content
and excludes the CELLPADDING. So it would suggest...

<TABLE WIDTH="400" BORDER="0" CELLSPACING="0" CELLPADDING="10">
<TR>
<TD WIDTH="80">
<TD WIDTH="80">
<TD WIDTH="80">
<TD WIDTH="80">
</TR>
</TABLE>

....is actually correct and many seem to agree with this too. I'd like to
think Adobe know more about it than I do but...

I have checked text books, the HTML 4.0 reference on w3.org, assorted
tutorials on the net and tried to check through newsgroup archives and I
still can't find a definitive answer. Most just say that the width is the
'column width' but do not say if that is the width of the content or of the
whole cell including padding.

So if we could ignore any factors like bad style and deprecation, I would
like to know which one is considered correct and ideally see some evidence
for why it is correct because I can't find it.
Graham
Jul 20 '05 #1
7 12155
"Graham J" <in***************@orangebucket.co.uk> wrote:

For many years I have been happily and successfully coding tables such that
the WIDTH
specified in a TD is the complete column width including any CELLPADDING.
For example for a 400 pixel wide table with four 100 pixel wide columns and
10 pixel cellpadding...

<TABLE WIDTH="400" BORDER="0" CELLSPACING="0" CELLPADDING="10">
<TR>
<TD WIDTH="100">
<TD WIDTH="100">
<TD WIDTH="100">
<TD WIDTH="100">
</TR>
</TABLE>

This is, to me, intuitive and is clearly how many others think it should be
done too judging by tutorials on the net and actual coding used. However
while using GoLive 6.01 (and this is not something I noticed with earlier
versions) I noticed that it considers that the WIDTH only covers the content
and excludes the CELLPADDING. So it would suggest...

<TABLE WIDTH="400" BORDER="0" CELLSPACING="0" CELLPADDING="10">
<TR>
<TD WIDTH="80">
<TD WIDTH="80">
<TD WIDTH="80">
<TD WIDTH="80">
</TR>
</TABLE>

...is actually correct and many seem to agree with this too. I'd like to
think Adobe know more about it than I do but...


Adobe is correct.

The HTML 4 spec says nothing on this isssue, probably because width is
deprecated. The HTML 3.2 spec is quite clear however,
http://www.w3.org/TR/REC-html32#table
"width
Specifies the suggested width for a cell content in pixels excluding
the cell padding."

And a simple test shows that
<table cellpadding="20" border="1" cellspacing="0"><tr><td
width="60">Hi!</td></tr></table> is rendered as being 100pixels wide
in Mozilla, IE6, Opera 7 and Netscape 4.

This is a good thing as it makes the move to CSS, where width is the
width of the content (IE bugs excepeted), easier.

Your first example "works" because browsers typically give more weight
to table widths and cellpaddiong values than they do to cell widths.
In other words the width="100" values are being ignored (though
perhaps the browser picks up on the fact that all the cells should be
the same width).

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 20 '05 #2
"Graham J" <in***************@orangebucket.co.uk>:
Apologies for the partial post that mysteriously escaped as I was composing.
I shall try again.

For many years I have been happily and successfully coding tables such that
the WIDTH
specified in a TD is the complete column width including any CELLPADDING.
For example for a 400 pixel wide table with four 100 pixel wide columns and
10 pixel cellpadding...

<TABLE WIDTH="400" BORDER="0" CELLSPACING="0" CELLPADDING="10">
<TR>
<TD WIDTH="100">
<TD WIDTH="100">
<TD WIDTH="100">
<TD WIDTH="100">
</TR>
</TABLE>

This is, to me, intuitive and is clearly how many others think it should be
done too judging by tutorials on the net and actual coding used. However
while using GoLive 6.01 (and this is not something I noticed with earlier
versions) I noticed that it considers that the WIDTH only covers the content
and excludes the CELLPADDING. So it would suggest...

<TABLE WIDTH="400" BORDER="0" CELLSPACING="0" CELLPADDING="10">
<TR>
<TD WIDTH="80">
<TD WIDTH="80">
<TD WIDTH="80">
<TD WIDTH="80">
</TR>
</TABLE>

...is actually correct and many seem to agree with this too. I'd like to
think Adobe know more about it than I do but...

I have checked text books, the HTML 4.0 reference on w3.org, assorted
tutorials on the net and tried to check through newsgroup archives and I
still can't find a definitive answer. Most just say that the width is the
'column width' but do not say if that is the width of the content or of the
whole cell including padding.

So if we could ignore any factors like bad style and deprecation, I would
like to know which one is considered correct and ideally see some evidence
for why it is correct because I can't find it.

The excercise is quite futile I prefer to think because you are not
providing the neccesary info about the kind of content you are putting
inside the cells nor what you want to achieve, i.e. an outside size of
400 or columns with max contentsize of 100 (80?).

And I would assume that after so many years succesfully coding tables
you could do the excercise yourself?

The table principle is that the table will first try to maintain the
width="400" if you insist on specifying that value.

However if you fill the 4 cells as follows:
<TD WIDTH="100"><img src="blue.gif" width="100" height="100"></td>
you will never have a table which is 400 wide.

On the other hand if you specify cells with text like so:
<TD WIDTH="100"><p>M M M M M M M M M M M M M M </p></td>
your table will attempt to remain at 400 (outside size incl. padding
and spacing).

A combination of 2x img + 2x text will result in 2 wide img cells and
2 narrow txt cells because you specified 400.

On the other hand if you are not specifying a width of 400, then all
combinations will give you the same result because the cells will try
to remain 100.

Copy this into a page and look/measure at the result:
<TABLE WIDTH="400" BORDER="1" CELLSPACING="0" CELLPADDING="10">
<TR>
<TD WIDTH="100"><img src="pics/dot_blue.gif" width="100"
height="100"></td>
<TD WIDTH="100"><img src="pics/dot_blue.gif" width="100"
height="100"></td>
<TD WIDTH="100"><img src="pics/dot_blue.gif" width="100"
height="100"></td>
<TD WIDTH="100"><img src="pics/dot_blue.gif" width="100"
height="100"></td>
</TR>
</TABLE>

<TABLE WIDTH="400" BORDER="1" CELLSPACING="0" CELLPADDING="10">
<TR>
<TD WIDTH="100"><p>M M M M M M M M M M M M M M </p></td>
<TD WIDTH="100"><p>M M M M M M M M M M M M M M </p></td>
<TD WIDTH="100"><p>M M M M M M M M M M M M M M </p></td>
<TD WIDTH="100"><p>M M M M M M M M M M M M M M </p></td>
</TR>
</TABLE>

<TABLE WIDTH="400" BORDER="1" CELLSPACING="0" CELLPADDING="10">
<TR>
<TD WIDTH="100"><img src="pics/dot_blue.gif" width="100"
height="100"></td>
<TD WIDTH="100"><img src="pics/dot_blue.gif" width="100"
height="100"></td>
<TD WIDTH="100"><p>M M M M M M M M M M M M M M </p></td>
<TD WIDTH="100"><p>M M M M M M M M M M M M M M </p></td>
</TR>
</TABLE>
<TABLE BORDER="1" CELLSPACING="0" CELLPADDING="10">
<TR>
<TD WIDTH="100"><img src="pics/dot_blue.gif" width="100"
height="100"></td>
<TD WIDTH="100"><img src="pics/dot_blue.gif" width="100"
height="100"></td>
<TD WIDTH="100"><img src="pics/dot_blue.gif" width="100"
height="100"></td>
<TD WIDTH="100"><img src="pics/dot_blue.gif" width="100"
height="100"></td>
</TR>
</TABLE>

<TABLE BORDER="1" CELLSPACING="0" CELLPADDING="10">
<TR>
<TD WIDTH="100"><p>M M M M M M M M M M M M M M </p></td>
<TD WIDTH="100"><p>M M M M M M M M M M M M M M </p></td>
<TD WIDTH="100"><p>M M M M M M M M M M M M M M </p></td>
<TD WIDTH="100"><p>M M M M M M M M M M M M M M </p></td>
</TR>
</TABLE>

<TABLE BORDER="1" CELLSPACING="0" CELLPADDING="10">
<TR>
<TD WIDTH="100"><img src="pics/dot_blue.gif" width="100"
height="100"></td>
<TD WIDTH="100"><img src="pics/dot_blue.gif" width="100"
height="100"></td>
<TD WIDTH="100"><p>M M M M M M M M M M M M M M </p></td>
<TD WIDTH="100"><p>M M M M M M M M M M M M M M </p></td>
</TR>
</TABLE>

John OO
--

<http://webcel.nl/>
<http://www.webcel.nl/bayshop/shop/bayshop.html>

"Time is what prevents everything from happening at once"
- John Archibald Wheeler -
Jul 20 '05 #3
> The HTML 4 spec says nothing on this isssue, probably because width is
deprecated. The HTML 3.2 spec is quite clear however,
http://www.w3.org/TR/REC-html32#table
"width
Specifies the suggested width for a cell content in pixels excluding
the cell padding."
[...snip...]


Thankyou, that was exactly what I wanted. I knew it must be there somewhere
:-)

Jul 20 '05 #4
> The excercise is quite futile I prefer to think because you are not
providing the neccesary info about the kind of content you are putting
inside the cells nor what you want to achieve, i.e. an outside size of
400 or columns with max contentsize of 100 (80?).
I think you are adding unnecessary complexity to the question and the simple
example code that was intended to clarify exactly what I was asking (should
it have been necessary).

Of course the content could affect the rendering but there is an
inconsistency in the code regardless of the content. The first example
would need a table width of 480 to be consistent with the cell widths.
And I would assume that after so many years succesfully coding tables
you could do the excercise yourself?


That relies on my knowing what the correct rendition is and I can't rely on
web browsers for that as they often do their own thing. For example I had a
page with a number of similar tables. Each had the same fixed width for the
tables and each had the width of the last three columns specified but I
hadn't specified the width of the first column (this wasn't deliberate, it
was just how it evolved). GoLive didn't have a problem in sizing the
columns on all the tables identically and nor did Safari. However Opera 7
and IE 6 rendered each table differently based on the (all textual) content.
Jul 20 '05 #5
"Graham J" <in***************@orangebucket.co.uk>:
The excercise is quite futile I prefer to think because you are not
providing the neccesary info about the kind of content you are putting
inside the cells nor what you want to achieve, i.e. an outside size of
400 or columns with max contentsize of 100 (80?).
I think you are adding unnecessary complexity to the question and the simple
example code that was intended to clarify exactly what I was asking (should
it have been necessary).

Believe me, your sample:
<TABLE WIDTH="400" BORDER="0" CELLSPACING="0" CELLPADDING="10">
<TR>
<TD WIDTH="100">
<TD WIDTH="100">
<TD WIDTH="100">
<TD WIDTH="100">
</TR>
</TABLE>
as I have proven in the previous post, is quite insufficient in
answering questions about tables even I did not mentioning the missing
</td>'s.
Of course the content could affect the rendering but there is an
inconsistency in the code regardless of the content. The first example
would need a table width of 480 to be consistent with the cell widths.
That's what I showed you, now where's your useless 400 and what is it
(not) doing?
And I would assume that after so many years succesfully coding tables
you could do the excercise yourself?


That relies on my knowing what the correct rendition is and I can't rely on
web browsers for that as they often do their own thing.


If someone knows how to write tablesource and believe me I know howto
code multiple nested tables by hand, without the use of a WYSIWYG
thingy, my webbrowsers from IE 3.x or N 4.x (the first I used) untill
the newest like Moz 1.4 or Opera 7.11 or even IE 6.0 will show the
same visual result.
For example I had a
page with a number of similar tables. Each had the same fixed width for the
tables and each had the width of the last three columns specified but I
hadn't specified the width of the first column (this wasn't deliberate, it
was just how it evolved). GoLive didn't have a problem in sizing the
columns on all the tables identically and nor did Safari.
Golive is not a browser.period.
However Opera 7
and IE 6 rendered each table differently based on the (all textual) content.

Even without examples I believe you, but in the case of tables, the
sourcecode actually used is the only way to explain why there was a
difference and what went wrong if there was a difference.

John OO
--

<http://webcel.nl/>
<http://www.webcel.nl/bayshop/shop/bayshop.html>

"Time is what prevents everything from happening at once"
- John Archibald Wheeler -
Jul 20 '05 #6
> Believe me, your sample:
<TABLE WIDTH="400" BORDER="0" CELLSPACING="0" CELLPADDING="10">
<TR>
<TD WIDTH="100">
<TD WIDTH="100">
<TD WIDTH="100">
<TD WIDTH="100">
</TR>
</TABLE>
as I have proven in the previous post, is quite insufficient in
answering questions about tables even I did not mentioning the missing
</td>'s.
As </TD> is optional according to the HTML 4.01 recommendation I don't think
you can say they are "missing". Desirable perhaps and in this case just
left out through oversight but not "missing".

I still maintain that code was 100% sufficient for illustrating the point.
It doesn't matter what the content is, the code would still be wrong.
However we obviously disagree on that. Thanks for your input anyway.
That's what I showed you, now where's your useless 400 and what is it
(not) doing?
It isn't useless because the idea was to illustrate incorrect code (though
code which a number of users are not aware is incorrect). If I left it out
or made it 480 the code would have been self-consistent and so totally
pointless as an example.

I know some feel that if you have widths specified for all the columns then
the table width will look after itself and is redundant and that is of
course true. However it can be useful in a WYSIWYG development environment
when first laying out tables, especially if the detail of the table is yet
to be finalised, and also for consistency checking of the numbers. Each to
their own.
Golive is not a browser.period.


No, but it renders HTML visually which is the important issue in this case.

Jul 20 '05 #7
> And a simple test shows that
<table cellpadding="20" border="1" cellspacing="0"><tr><td
width="60">Hi!</td></tr></table> is rendered as being 100pixels wide
in Mozilla, IE6, Opera 7 and Netscape 4.

This is a good thing as it makes the move to CSS, where width is the
width of the content (IE bugs excepeted), easier.

Yep.But there is also <TD height=something > case.
Mozilla and IE will treat this something as a height of outer margin of the
cell (including padding).
Only Opera is consistent treating width and height in the same manner.
Your first example "works" because browsers typically give more weight
to table widths and cellpaddiong values than they do to cell widths.
In other words the width="100" values are being ignored (though
perhaps the browser picks up on the fact that all the cells should be
the same width).


To be precize this values will be used as weights (as like percentage) for
real column width computation.

Andrew Fedoniouk.
http://blocknote.net

Jul 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
by: MattB | last post by:
Hello please help, I have a table cell with a div in it. The div has a width of 300px. but when it is rendered it puts extra space into the table cell. Here's the style <style>...
4
by: Hiwj | last post by:
I am having a problem with a cell in a table in ASP.NET which used to work OK in classic ASP. I have one cell in a row where the width should be 22 pixels and the other cell should take up the...
50
by: Shadow Lynx | last post by:
Consider this simple HTML: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 STRICT//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head>...
2
by: Charleees | last post by:
Hi all, I have a DataGrid with Template Columns..... There are LAbels,Linkbuttons in the Single Row.. I have to set the Constant Column width for those Template Columns in Grid... Wat...
8
by: hussain123 | last post by:
Hi List, I am having two table one after the another.Even after setting the column width of both the tables the column takes the width of the data in that column. Ideally I want both the table's...
4
by: bb nicole | last post by:
Below is my coding for the login and ticker. I put both of it in table which width=166 and height=188, but the size of both table was not same, one is wider and one is narrow...My problem now is when...
1
by: RichardR | last post by:
I have a webpage which has a table that contains a column with several drop down boxes (<SELECT>). The contents of the drop down boxes are dynamically populated so I have no idea what the actually...
1
dmjpro
by: dmjpro | last post by:
Here is my HTML code <table width="100%" border="0" cellspacing="0" cellpadding="2"> <tr> <td class="header_inactivated"...
10
by: magnesium | last post by:
I have this under-construction page, If you try and select the link coming from the bottom with your mouse, you'll notice, that before the actual link is selected, the td background will change. you...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.