Connecting Tech Pros Worldwide Forums | Help | Site Map

Table row height difference between IE and Firefox

Newbie
 
Join Date: Dec 2006
Posts: 12
#1: Dec 26 '06
I have extracted the following code and eliminated a lot of HTML and CSS so that I can isolate a problem. Essentially, IE does what I expect (!!) and other browsers make the row height much larger than I expect (enough white space for 3 rows of text). Here's the HTML:

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title></title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. </head>
  7. <body>
  8.  <table border="1"><TR>
  9. <TD><p>Sample text</p></TD>
  10. </TR></table>
  11. </body>
  12. </html>
I have discovered that if I remove the <p> tags, then Firefox no longer renders a tall row. But why? And is there something I can do in my CSS or HTML to eliminate this problem? (I have this problem in a lot of places and it isn't as simple as just deleting the <p> tags because they serve other functions.)

I have tried all sorts of combinations of height, row-height, etc. to override this unexpected behaviour. But so far nothing seems to do the trick.

Any ideas?

Expert
 
Join Date: Oct 2006
Location: NC
Posts: 1,722
#2: Dec 26 '06

re: Table row height difference between IE and Firefox


Change your doc type to this:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2. "http://www.w3.org/TR/html4/strict.dtd">
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,577
#3: Dec 26 '06

re: Table row height difference between IE and Firefox


First of all, in xhtml, case matters so put your tags in lower case.
Also, your meta is missing the ending slash />. xhtml requires this.

The reason the row collapses is because the margins from the <p> no longer exist. To get around this, set all your margins to zero and add them where needed. *{margin:0} This also alleviates problems where default margins are different between browsers.
Newbie
 
Join Date: Dec 2006
Posts: 12
#4: Dec 26 '06

re: Table row height difference between IE and Firefox


Those were interesting ideas but they do not appear to have changed anything. Here's what I have now:

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title></title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  6. </head>
  7. <body style="margin:0">
  8. <table border="1"><tr>
  9. <td><p>Sample text</p></td>
  10. </tr></table>
  11. </body>
  12. </html>
The only visible difference is that in both browsers, the table moved to the upper left corner. Firefox still has a lot of wasted space insde the table, above and below the words "Sample text", while IE does not.

Did I do what you both had in mind?
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,577
#5: Dec 26 '06

re: Table row height difference between IE and Firefox


They aren't ideas, it's the standard, that's why you needed to change them. Though they didn't affect what you have now, it could have significance later.

You didn't quite do what I said. In your head, add this:

Expand|Select|Wrap|Line Numbers
  1. <style type="text/css">
  2. * {margin:0}
  3. </style>
The * is a wildcard meaning "everything".
Newbie
 
Join Date: Dec 2006
Posts: 12
#6: Dec 26 '06

re: Table row height difference between IE and Firefox


That certainly fixed it. Thanx!

If I place this at the top of my style sheet before my other CSS, will it be effectively overridden by all of the subsequent statements?
Newbie
 
Join Date: Dec 2006
Posts: 12
#7: Dec 26 '06

re: Table row height difference between IE and Firefox


Curious ... as soon as I moved that to the top of my style sheet, it stopped working. The only way I can get it working is to combine the inline margin spec with the link to my stylesheet as follows:

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title></title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  6. <style type="text/css">
  7. * {margin:0}
  8. </style>
  9. <link rel=stylesheet href="../WGCstyle.css" type="text/css" />
  10. </head>
  11. <body>
  12. <table border="1"><tr>
  13. <td><p>Sample text</p></td>
  14. </tr></table>
  15. </body>
  16. </html>
Can you explain why that is?
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,577
#8: Dec 26 '06

re: Table row height difference between IE and Firefox


The code I gave you will override all default margins but not anything you set.

I don't understand what you mean. Just put the *{margin:0} at the top of your external style sheet but remove the <style></style> stuff.
Newbie
 
Join Date: Dec 2006
Posts: 12
#9: Dec 26 '06

re: Table row height difference between IE and Firefox


I did (at least I think I did it properly). My external stylesheet begins:

Expand|Select|Wrap|Line Numbers
  1. <style>
  2.     *    {margin:0}
  3.     p, body    {color: #000000; font-family: Verdana, Arial; text-align: left; font-size: 13px}
  4.     .normal    {color: #000000; font-family: Verdana, Arial; text-align: left; font-size: 13px; 
  5.         margin-left:10px;}
  6.     .adminaction    {color: #000000; font-family: Verdana, Arial; text-align: left; font-size: 13px; 
  7.         margin-left:20px;}
The page is as shown in my latest post above.

Sorry if I did something stupid ... but I can't get it to work unless I also put the inline style code there too.
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,577
#10: Dec 26 '06

re: Table row height difference between IE and Firefox


You don't use style tags in stylesheets. Remove the <style> stuff.
Expert
 
Join Date: Oct 2006
Location: NC
Posts: 1,722
#11: Dec 27 '06

re: Table row height difference between IE and Firefox


If that doesn't fix it post the code your using to link the style sheet.
Newbie
 
Join Date: Dec 2006
Posts: 12
#12: Dec 27 '06

re: Table row height difference between IE and Firefox


Wow ... can't believe that I didn't know that. I've been building all style sheets with the <style> tags since the dawn of CSS and never had a problem.

<sigh />

I took it out and it started working properly. Will post again if anything unexpected occurs, but hopefully this is it on this problem.

Thanx again. Good help is hard to find!
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,577
#13: Dec 27 '06

re: Table row height difference between IE and Firefox


More advice. Don't use tables for layout.
Newbie
 
Join Date: Dec 2006
Posts: 12
#14: Dec 27 '06

re: Table row height difference between IE and Firefox


I understand the reasons to avoid tables, and I do try to avoid them, but when you are maintaining server-side code generated 5+ years ago, there isn't a lot of choice. And sometimes a simple table is a lot easier to use than trying to accomplish the same thing in CSS. (I expect that religious wars are fought over this issue, not unlike "go-to-less" programming 20 years ago.)

On the original problem, I'm somewhat surprised at the repercussions this has had on existing tags in my pages. No spacing between paragraphs, bullets that no longer show up, etc. Is there any useful set of definitions you use for common tags like p and bullets to save me reinventing all of this? Or any web reference on the subject I can learn from?
Expert
 
Join Date: Oct 2006
Location: NC
Posts: 1,722
#15: Dec 27 '06

re: Table row height difference between IE and Firefox


W3 Schools is a popular place to learn HTML. What do you mean your bullets aren't showing up?
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,577
#16: Dec 27 '06

re: Table row height difference between IE and Firefox


I didn't know this was for an older page so I can understand the problems you may be having from using the * for margins. Sometimes you can use 'conditional comments' to insert things for IE only. It works like this:

[<!--[if lt IE 7]>
p{margin:0}
<![endif]-->

Which reads as "if less than IE7", etc.

Short tutorial link but google for "conditional comments" for lots more including MS doc page on it.
Newbie
 
Join Date: Dec 2006
Posts: 12
#17: Dec 27 '06

re: Table row height difference between IE and Firefox


I have numerous reference sites bookmarked and have been writing HTML since about 1995. I have no problem investing time to learn what's changing but with the number of technologies there are, there simply isn't enough time to stay current on all the evolving languages and specs that exist.

At the moment, I'm just a little frustrated that my desire to clean up one inconsistency between IE and Firefox has resulted in a cascading set of issues in my pages. And yes, it would have been nice if they didn't contain errors, but when I last ran this stuff thru a checker they were considered clean. I guess the specs changed and I didn't notice.

I've just read a bunch of stuff on margins and containers and am not getting the results I had hoped for. Think I'll put this back on the shelf, return the code to what I started with, and when my current project is finished, try to understand what has been happenning. Fortunately most of my users run IE.

Thanx for helping. Maybe talk to you in January.
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,577
#18: Dec 27 '06

re: Table row height difference between IE and Firefox


Sometimes the best bet is to tear it up and start over. The fact that your users are IE is not fortunate. You will have to write proper, standard code; then adjust it for IEs quirks and bugs; but it shouldn't be too hard if they upgrade to IE7 by then at least.
Newbie
 
Join Date: Apr 2007
Location: india
Posts: 1
#19: Apr 4 '07

re: Table row height difference between IE and Firefox


Hi,

It is simple solution :
Expand|Select|Wrap|Line Numbers
  1. p {
  2.         margin:0px;
  3.         }
Thanks
Narendra singh
Newbie
 
Join Date: Sep 2008
Posts: 1
#20: Sep 28 '08

re: Table row height difference between IE and Firefox


Try using div tags instead, like this

INSTEAD OF:
<td><p>Sample text</p></td>

USE:
<td><div>Sample text</div></td>
Newbie
 
Join Date: Oct 2008
Posts: 1
#21: Oct 4 '08

re: Table row height difference between IE and Firefox


I know this is really old, but for what it's worth:

After setting * {margin:0px}, bring back individual margins you need like this:

ol, ul {margin-left:20px}

p {margin:10px 0px 10px 0px}

You can set whatever values you want, of course, but I have found that 20px left margin is the minimum required to bring back bullets or numbers in lists
Reply


Similar HTML / CSS bytes