Click here to get back home

Div left margin getting double size on IE6. Why?

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Div left margin getting double size on IE6. Why? Neviton 05-12-2008
Posted by Neviton on May 12, 2008, 1:10 pm
Please log in for more thread options
Hi this is the html to generate the behavior:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<body style="margin: 0px; padding: 0px;">
        <div style="margin-left: 10px; float: left;">
                <div id="test" style="background-color: red;">
                        test
                </div>
        </div>
</body>
</html>

I used margin-left: 10px but IE6 show a margin with 20px.

If I remove the style "float: left;" this way:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<body style="margin: 0px; padding: 0px;">
        <div style="margin-left: 10px;">
                <div id="test" style="background-color: red;">
                        test
                </div>
        </div>
</body>
</html>

the IE6 show the right margin.

Please help-me!!!
or my boss will kill me ;)

Posted by Andy Dingley on May 12, 2008, 1:25 pm
Please log in for more thread options
> Hi this is the html to generate the behavior:

Don't post fragments or complete pages, post URLs to publically
accessible examples.

> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Why use XHTML? For XHTML to even begin to be a good idea, you must
know why you're doing it, appreciate why you shouldn't do it,
understand what precise benefit using it will give you for this
precise example, then show that there actually is such a benefit.
There almost never is such a benefit.

Why use Transitional? As for XHTML, maybe even more so.

Use HTML 4.01 Strict instead, all the time, unless you can argue a
good case for it with the audience here.


> <html xmlns="http://www.w3.org/1999/xhtml" >
> <body style="margin: 0px; padding: 0px;">

Where's the <head> and <title> elements?

This code is invalid. That means three or four things at least:

* You haven't read the newsgroup, or understood the importance of
using valid markup.
** You don't appreciate that posting invalid code here is just going
to generate a "Post valid code" response.

* Invalid code makes IE go bananas. A basic starting point for keeping
it under control is to only feed it valid code.

* You don't validate your code as a matter of course. _Anything_ could
be hiding in there.

* We don't have time to fix valid code. We certainly don't have time
to mess with invalid stuff. Do the basics yourself first.


> I used margin-left: 10px (and float:left;) but IE6 show a margin with 20px.

Go and read http://brainjar.com/css/positioning/ on the meaning and
effects of "width" and "margin" when applied to floated elements. You
need to understand what float means first of all before using it. In
particular the stuff about floated elements being taken out of the
normal flow of rendered elements.


> Please help-me!!!
> or my boss will kill me ;)

We're still thinking about it.

Posted by Neviton on May 12, 2008, 1:50 pm
Please log in for more thread options
Man whats your problem?
Are you angry?

If I have asked for help is cause I dont know how to do what I need.

Could you undestand it?

I dont put head e title element just to let the code smaller to post
and this dont make difference to show what I want.

please if dont have patience just let me without your help.

I just though I would find some help on it.

And sorry if I made your day more bad.

Posted by Neviton on May 12, 2008, 2:08 pm
Please log in for more thread options
Andy Dingley
Whats your problem?
Are you angry?

If I have asked for help is cause I dont know how to do what I need.

Could you undestand it?

I dont put head e title element just to let the code smaller to post
and this dont make difference to show what I want.

please if dont have patience just let me without your help.

I just though I would find some help on it.

And sorry if I made your day more bad.

Posted by Steve Pugh on May 12, 2008, 1:46 pm
Please log in for more thread options
> Hi this is the html to generate the behavior:
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www=
.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns=3D"http://www.w3.org/1999/xhtml" >
> <body style=3D"margin: 0px; padding: 0px;">
> =A0 =A0 =A0 =A0 <div style=3D"margin-left: 10px; float: left;">
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 <div id=3D"test" style=3D"background-color=
: red;">
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 test
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 </div>
> =A0 =A0 =A0 =A0 </div>
> </body>
> </html>
>
> I used margin-left: 10px but IE6 show a margin with 20px.

Known bug with IE6. If you float to one side it doubles the margin on
the same of the floated element.

See http://www.positioniseverything.net/explorer/doubled-margin.html


Steve





Similar ThreadsPosted
Boxes with extra margin (or wrong size) October 24, 2006, 10:43 am
Double-spacing 1st List Level, but not Nested Levels July 9, 2006, 8:24 pm
margin above of

August 23, 2007, 5:15 am
What good is margin-bottom in IE? November 3, 2004, 1:28 pm
Help with Firefox margin issue August 30, 2005, 5:26 pm
Netscape margin attributes June 2, 2006, 2:47 pm
strange behavior with IE and margin... June 12, 2006, 2:03 am
after setting 's margin to 0 it is still non zero! (IE only) January 18, 2007, 12:54 pm
margin under floated divs February 14, 2008, 1:06 pm
Firefox - Prevent TextField size change when user changes font size? October 3, 2006, 6:21 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap