Wrox Programmer Forums
|
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 5th, 2005, 11:37 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default IE5 Problem with divs

I've got this problem with IE5, I'm trying to do a simple layout like this using divs:

Code:
|---------------|
|page           |
| |-------------|
| | banner      |
| | |-----------|
| | | menu      |
| | |-----------|
| |-------------|
| |             |
| | content     |
| |             |
| |-------------|
| | footer      |
|---------------|
The problem is that in IE5 I've got gaps between the banner, content and footer divs. Take a look at the attached example HTML and you'll see what I mean - I don't want the blue bits between the banner and content, nor between the content and footer!
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html lang="en" dir="ltr">
<head>
    <title>template test</title>
    <style type="text/css">
        #page
        {
            border-width: 1px;
            border-style: solid;
            border-color: #666666;
            background-color: blue;
        }
        #banner
        {
            border-width: 1px;
            border-style: solid;
            border-color: #666666;
            background-color: red;
        }
        #menu
        {
            border-width: 1px;
            border-style: solid;
            border-color: #666666;
            background-color: green;
        }
        #content
        {
            border-width: 1px;
            border-style: solid;
            border-color: #666666;
            background-color: yellow;
        }
        #footer
        {
            border-width: 1px;
            border-style: solid;
            border-color: #666666;
            background-color: purple;
        }
    </style>
</head>

<body>
    <div id="page">Page start
        <div id="banner">Banner start

            <h1>banner text</h1>

            <div id="menu">
          menu text
            </div>
         Banner end</div>

        <div id="content">
            <h2>Page Title</h2>
            <p>page content</p>

        </div>
        <div id="footer">
            &copy; footer
        </div>

  Page end</div>
</body>
</html>
It looks fine in IE6 and Firefox, the only blue is at the top and bottom, which is just what I want.

Anyone know why this is - feel free to rant about how buggy IE5 is, as long as you give me the answer too ;)

thanks
Phil
 
Old February 5th, 2005, 12:32 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Phil,

The only reason I can think of is the layout of the HTML. Did you try removing all the white space from the code?

I don't have IE 5.x here right now, so I can't test. At first I thought this was due to IE's buggy box model implementation, but you're not using any fixed width with padding/margin anywhere, so I think it has to be the code formatting....

If that doesn't help, let me know and I'll try to get what you see in IE 5.x.

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old February 5th, 2005, 03:56 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Imar, removing the whitespace didn't work.

Phil
 
Old February 5th, 2005, 04:02 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 425
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Are you referring to IE5 Mac? Cause I don't see the problem on Windows.

(o<
//\ =^..^=
 
Old February 6th, 2005, 05:36 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

No I mean IE5 Win. I've got v5.00.2614.3500IC
 
Old February 6th, 2005, 06:14 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 425
Thanks: 0
Thanked 3 Times in 3 Posts
Default

That's interesting. 5.00.2614.3500 would be IE5 (note NOT 5.01) on Win98 SE. Does that sound right to you? And what does IC stand for? Is this a modified version?

I've got 5.01 on NT. The standalone version but it has been accurate so far. If the above is right, I doubt that there are many 5 left. Most people would have upgraded to 5.01, I think. On the other hand I don't know if there were any rendering differences between the two. What a mess!

(o<
//\ =^..^=
 
Old February 6th, 2005, 06:39 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Phil,

I think this is caused by the default padding and margin that is added to elements like p and h2 in earlier browsers. (These elements still have padding and margin but they seem to interfere less with backgrounds etc).

I ran a quick test on a virtual machine with Win98 and IE4 and I was able to fix the problem by adding the following selector:

p, h2
{
    margin: 0;
    padding: 0;
}

This removes the standard padding and margin from the p and h2, causing the blue areas to disappear.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old February 6th, 2005, 02:14 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thanks Imar, you're a star, it is the margin on the emedded block elements that's causing the probs.

and thanks to meow too - it is IE5 on Win98 SE, and I have no idea what the IC stands for!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Tables or divs gujjar CSS Cascading Style Sheets 1 January 9th, 2007 08:13 AM
divs inside divs: theory? Giant_robot_sandwich CSS Cascading Style Sheets 11 September 13th, 2006 03:56 PM
About XML-DSO on IE5 programming reference qualsn Wrox Book Feedback 1 December 5th, 2003 10:13 AM
Works with IE5 and IE6, but not NS vincentms Beginning PHP 8 August 14th, 2003 06:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.