473,748 Members | 8,367 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Table column widths vs. Cell padding

I seem to having a little trouble getting a table to display correctly
in both msie and firefox. I want to set the table and column widths in
pixels, and have some cell padding too. The table displays correctly
in standards compiance mode in firefox, but not msie, where the
padding is added on to the column widths.
the table size is always correct, but the column widths are not what I
expect them to be.

If I change the column widths to be smaller by the padding x 2, the
table displays correctkly in msie, but not in firefox :(

Which browser is actually conforming to the CSS2 spec?

Does anyone know a proper fix for this? (preferably no css hacks)

The code is below:-

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style>
<!--
table { font-family: Arial; font-size: 10px }
#testtable { width: 400px; table-layout: fixed;
border-collapse: collapse }
#testtable td { overflow: hidden; border: 1px solid black;
margin: 5px }
#testtable col#col1 { width: 40px }
#testtable col#col2 { width: 60px }
#testtable col#col3 { width: 140x }
#testtable col#col4 { width: 160px }
-->
</style>
</head>
<body>
<table id='testtable'>
<col id="col1"><col id="col2"><col id="col3"><col id="col4">
<tbody>
<tr>
<td>01234567890 123456789012345 67890123456789</td>
<td>A</td>
<td>1.00%</td>
<td>C</td>
</tr>
<tr>
<td>1</td>
<td>A1</td>
<td>2.00%</td>
<td>C1</td>
</tr>
<tr>
<td>2</td>
<td>A2</td>
<td>4.00%</td>
<td>C2</td>
</tr>
<tr>
<td>1</td>
<td>A1</td>
<td>8.00%</td>
<td>C1</td>
</tr>
<tr>
<td>2</td>
<td>A2</td>
<td>16.00%</td>
<td>C2</td>
</tr>
<tr>
<td>1</td>
<td>A1</td>
<td>32.00%</td>
<td>C1</td>
</tr>
<tr>
<td>2</td>
<td>A2</td>
<td>64.00%</td>
<td>C2</td>
</tr>
<tr>
<td>1</td>
<td>A1</td>
<td>128.00%</td>
<td>C1</td>
</tr>
<tr>
<td>2</td>
<td>A2</td>
<td>256.00%</td>
<td>C2</td>
</tr>
</tbody>
</table>
</body>
</html>

cheers,
Steve
Jul 20 '05 #1
3 10713
Steve Sabljak wrote:

<snip>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style>
<!--
table { font-family: Arial; font-size: 10px }
#testtable { width: 400px; table-layout: fixed;
border-collapse: collapse }
#testtable td { overflow: hidden; border: 1px solid black;
margin: 5px }
#testtable col#col1 { width: 40px }
#testtable col#col2 { width: 60px }
#testtable col#col3 { width: 140x }


I don't use the <col> element, but I have noticed the above mistake. I'm
quite interested in whether that will fix the problem or not.

Paul
Jul 20 '05 #2
DU
Steve Sabljak wrote:
I seem to having a little trouble getting a table to display correctly
in both msie and firefox. I want to set the table and column widths in
pixels, and have some cell padding too. The table displays correctly
in standards compiance mode in firefox, but not msie, where the
padding is added on to the column widths.
the table size is always correct, but the column widths are not what I
expect them to be.

If I change the column widths to be smaller by the padding x 2, the
table displays correctkly in msie, but not in firefox :(

Did you check the specs on all this to begin with?
Just today, I filed a bug related to this precise issue.

"If column widths prove to be too narrow for the contents of a
particular table cell, user agents may choose to reflow the table."
http://www.w3.org/TR/html401/struct/...tml#h-11.2.4.4

"If a table or given column has a fixed width, cellspacing and
cellpadding may demand more space than assigned. User agents may give
these attributes precedence over the width attribute when a conflict
occurs, but are not required to."
http://www.w3.org/TR/html401/struct/....html#h-11.3.3
Which browser is actually conforming to the CSS2 spec?

Does anyone know a proper fix for this? (preferably no css hacks)

The code is below:-

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style>
<!--
table { font-family: Arial; font-size: 10px }
#testtable { width: 400px; table-layout: fixed;
border-collapse: collapse }
Why do you absolutely need to set a width to the table? I'm just asking
this because setting an abs. width to a table is usually the start of a
very common problem found in webpages which is called "over-constrained
table"
#testtable td { overflow: hidden; border: 1px solid black;
margin: 5px }
#testtable col#col1 { width: 40px }
#testtable col#col2 { width: 60px }
#testtable col#col3 { width: 140x }
#testtable col#col4 { width: 160px }
-->
</style>
</head>
<body>
<table id='testtable'>
<col id="col1"><col id="col2"><col id="col3"><col id="col4">
<tbody>
<tr>
<td>01234567890 123456789012345 67890123456789</td>


Is this realistic? No blank space in a 40 character word? and you're
allowing only 40 px. You're the one creating the problem on purpose, it
seems. I ddon't understand your post anymore.

DU
Jul 20 '05 #3
Paul <pa***********@ blueyonder.couk > wrote in message news:<qI******* ************@fe 1.news.blueyond er.co.uk>...
Steve Sabljak wrote:

<snip>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style>
<!--
table { font-family: Arial; font-size: 10px }
#testtable { width: 400px; table-layout: fixed;
border-collapse: collapse }
#testtable td { overflow: hidden; border: 1px solid black;
margin: 5px }
#testtable col#col1 { width: 40px }
#testtable col#col2 { width: 60px }
#testtable col#col3 { width: 140x }


I don't use the <col> element, but I have noticed the above mistake. I'm
quite interested in whether that will fix the problem or not.

Paul


Oops!! I meant 'padding: 5px', not 'margin: 5px'

-Steve
Jul 20 '05 #4

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

Similar topics

1
7119
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> #treecontainer {
3
3069
by: Grytpype-Thynne | last post by:
Hello, Is it possible to align a column in a table so that units, tens and hundreds (some may not go to hundreds) align correctly yet are in the center of the table cell? I can get them to line up in units, tens and hundreds by using right align and right padding and a monospace font but where the columns are of different widths they don't centralize, is it possible to put the numbers in a box and then center the box in the cell? The...
0
2624
by: TJ Talluto | last post by:
<facts> I have a "month calendar" that always displays exactly 42 days... and alongside is a vertical box that displays the detail (form fields) of any particular select event that appears on the calendar, so that the event may be changed, or a new event may be created. monthname X X X X X X X form X X X X X X X form X X X X X X X form
4
26209
by: N. Demos | last post by:
The following code renders as intended in IE (A TABLE, with cells of fixed width and height, inside of a DIV with fixed width and height and overflow set to hidden.) In Firefox, the table cells assume a narrower with than specified. If I comment out the width for the DIV, then the cells render with the correct width and height. Why is this happening? Thanks. Regards, N. Demos
1
12301
by: Jeronimo Bertran | last post by:
I am creating a table and inserting an iframe inside a cell for which the width depends on the screen size. The table has 7 columns and the fourth column is resized depeding on the screen size... here is my complete definition. <table style="HEIGHT: 472px" cellSpacing="0" cellPadding="0" width="100%" border="0"> <tr height="1">
18
30572
by: chimalus | last post by:
I am using a table with no column widths specified, letting the table layout manager do its thing for figuring out the column widths, and this works just fine. Now I want to make the table dynamic. I have added a filtering mechanism (in javascript) that can be used to hide unneeded rows. However, each time I hide or show rows, the column sizes change, and this doesn't look good. Is there a way that I can preserve the column widths...
117
18555
by: phil-news-nospam | last post by:
Is there really any advantage to using DIV elements with float style properies, vs. the old method of TABLE and TR and TD? I'm finding that by using DIV, it still involves the same number of elements in the HTML to get everything just right. When you consider the class attribute on the DIV elements, there's not much size savings anymore for using DIV. There are other disadvantages to not using TABLE/TR/TD, such as the lack of ability...
1
3421
by: jamesm6162 | last post by:
Hi I have the following XSL-FO document that I'm testing with the FOP processor. The table I put in, however, is completely stuck to the left side of the body-region, regardless of which margins or paddings I insert. How do I indent the whole table? This is extremely frustrating. Thanks <fo:flow flow-name="xsl-region-body"> <fo:block space-before="5mm" margin="5mm" border-style="groove" border-width="0mm" border-color="blue"...
5
4954
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums there are, it crashes. There are currently 6 columns, and I only want 4. How do I remove the last two (discount and date)? Here is a link: http://www.jaredmoore.com/tablesorter/docs/salestable.html Here is some jquery js that I think...
0
8984
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9530
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9312
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9238
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8237
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4593
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.