View Full Version : How can I get IE7 to interprete #include without an anoying 'margin'

06-16-2010, 03:33 PM
I'm having my HeaderLogo + Menu in an #include file (header_inc.htm) to have it in all web-pages.
In IE7 the pages (header) start with a blank space line 10-15px, and in IE8 and most other it doesn't start with this kind of 'margin'.

I thought that it had something to do with CSS and styles of divs but it can't be as if I do copy all text of #include file into the pages there is no 'margin' showed, which is what I want. But I really need the menu to be included to have minimal changes instead of 1000s of changes.

Any clues what I can do for the IE7 and other browsers that interprete the #include with a 'margin' of 10-15px ?

Thanks in advance :thumbsup:

06-16-2010, 03:43 PM
It must be something in your css or a different default margin setting - the include by itself will not introduce any extra margin.

Have you reset all your paddings/margins to zero via:


If you have, then it must be something else and we need a link to your page.

06-17-2010, 09:45 AM
First I want to thank you for your quick reply :thumbsup:

I have tried all kind of margins/paddings to 0 - and why I say it can't be something with the CSS is that - if I copy the whole content of the include (pure HTML) and paste it into a few of the pages instead of the :
<!--#include virtual="/header_inc.htm"-->line, there is no whitespaces at top.
It is only IE7 and ApleSafari 4.0.4 I have tested to do it wrong :confused:
IE8, Opera, FireFox does it well :thumbsup:

I can't for now give you a link to website - but I might find a way later to reconstructor a similar page on another server.

Thanks for trying :thumbsup:

PS. I did try *{margin:0px;padding:0px} just in case :)

06-17-2010, 03:31 PM
ok - I have made 2 mini-shtml files that is exactly the same content vice, but the 1st of them is having the header in an #include-file and the 2nd I have copied the exact html from the include-file into the shtml-page (which shouldnt actually be an shtml anymore as there is no server-request anymore but anyway)

In IE7 the included page, with include (http://www.pssenergi.dk/testing.shtml), is showing a horizontal white-space, as if there was a margin, instead of having the logo inTop as in without include (http://www.pssenergi.dk/testing2.shtml)!

I've set the 2 files link to the right of content so you can togle it there :p

Maybe its one.com's server-response that does it - I unfortunately couldn't try it out on my other server, as it hasn't a server-response activated :rolleyes:
I will appreciate it very mucy if any1 can try that out for me :D

Thanks in advance

06-17-2010, 04:50 PM
Comparing the two files using the IE Dev toolbar your page with the include shows as having some text both before and after the comment "<!-- Begin of Header //-->". I'm guessing that this might be a space. Are there any space characters before your include? If so try deleting these...

Ah, same problem in Chrome - which shows two quotes and a dash appearing in the html before the include.

EDIT: Your <meta> and <link> elements are closed - which isn't required with HTML4 (only with XHTML) - the validator is throwing this as an error - worth sorting these (http://validator.w3.org/check?uri=http://www.pssenergi.dk/testing.shtml&charset=(detect+automatically)&doctype=Inline&group=0) out as well.

06-17-2010, 07:23 PM
I have done that before - but just to be sure I deleted all coments....

I can't check it here (home) as I don't have IE7 installed :rolleyes:

So I actually doesn't know if it cured the problem - but my guess is that it didn't.
Ok - I just tried the Browser Sandbox (http://spoon.net/browsers/) to simulate IE7 and it's still the same :(