I have a complete tableless web layout that I designed in PS CS4 and exported the slices. I created a CSS file and then switched all the tables to DIVs and created classes in the CSS file for each of them. For some reason when it is loaded into IE8 there seems to be an extra 4-6 px space around the divs. But when loaded into firefox it looks perfect. I have never run into this issue before so I am not sure what the problem is.

Here is the HTML:

<html>
<head>
<title>598760 - Index2</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="stylesheets/public.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
  <div id="header_logo"><img src="images/header_logo.jpg" /></div>
  <div id="header_right"><img src="images/header_right.jpg" /></div>
  <div id="menubar"><img src="images/menubar.jpg" /></div>
  <div id="sep1"><img src="images/sep1.jpg" /></div>
  <div id="sep2"><img src="images/sep2.jpg" /></div>
  <div id="mid_wrapper">
    <div id="nav_wrapper">
      <div id="menu_nav_header"><img src="images/menu_nav_header.jpg" /></div>
      <div id="menu_nav_body">
       <img id="img_nav" src="images/menu_nav_body.jpg" usemap="#img_nav" />
      <map id="img_nav">
        <area shape="rect" coords="30,10,196,35" href="home" alt="Home" title="Home" />
        <area shape="rect" coords="30,39,196,64" href="Login" alt="Login or Register" title="Login or Register" />
        <area shape="rect" coords="30,68,196,93" href="About" alt="About Us" title="About Us" />
        <area shape="rect" coords="30,101,196,126" href="Terms of Use" alt="Terms of Use" title="Terms of Use" />
        <area shape="rect" coords="30,130,196,155" href="Privacy Policy" alt="Privacy Policy" title="Privacy Policy" />
      </map>
      </div>
    </div>
    <div id="upper_body"><img src="images/upper_body.jpg" /></div>
  </div>
  <div id="sep3"><img src="images/sep3.jpg" /></div>
  <div id="main_body">
  <!-- ########## START MAIN CONTENT HERE ########## -->
  <br />
  <br />
  <br />
  <br />
  <br />
  <!-- ########## END MAIN CONTENT HERE ########## -->
  </div>
  <div id="footer"><img src="images/footer.jpg" /></div>
</div>
</body>
</html>

Here is the CSS code:

#wrapper {
	margin:auto;
	width:940px;
	padding:0px;
}
#header_logo {
	width:719px;
	height:100px;
	vertical-align:top;
	float:left;
}
#header_right {
	width:221px;
	height:100px;
	vertical-align:top;
	float:right;
}
#menubar {
	width:940px;
	height:40px;
	vertical-align:top;
	clear:both;
}
#sep1 {
	width:220px;
	height:10px;
	vertical-align:top;
	float:left;
}
#sep2 {
	width:720px;
	height:10px;
	vertical-align:top;
	float:right;
}
#mid_wrapper {
	width:940px;
	height:205px;
	vertical-align:top;
}
#nav_wrapper {
	width:220px;
	height:205px;
	vertical-align:top;
	float:left;
}
#menu_nav_header {
	width:220px;
	height:40px;
	vertical-align:top;
	float:left;
}
#menu_nav_body {
	width:720px;
	height:205px;
	vertical-align:top;
	float:left;
}
#upper_body {
	width:720px;
	height:205px;
	vertical-align:top;
	float:right;
}
#sep3 {
	width:940px;
	height:10px;
	vertical-align:top;
	clear:both;
}
#main_body {
	width:936px;
	border:2px solid #9c9c9c;
	background-color:#f6f6f6;
}
#footer {
	width:940px;
	height:50px;
}
body {
	background-color:#FFF;
	margin:auto;
	padding:0px;
}
img {
	border:none;
	margin:0;
	padding:0;
}
a {
	color:#FF0000;
}

Here is a link to the page live on the web on my server:

I appreciate any help at all. Thanks in advance.

-Jason

Dani AI

Generated

— good catch that adding a DOCTYPE removed the 4–6px gap. Missing/incorrect DOCTYPE puts IE into “quirks” mode where box-model behavior, default margins and baseline alignment differ from standards mode; that often produces small, inconsistent gaps across browsers. See MDN for a concise explanation of Doctype/quirks vs standards mode (link below).

Two practical things to check next (they’re quick and will prevent future surprises):

  • Image maps and duplicate IDs: avoid giving the same id to more than one element. Older IE variants look for a map by its name attribute, so give the <map> a name (and an id if you like) and keep element ids unique. That makes usemap work consistently across engines; run the page through the W3C validator to spot duplicate ids and other markup issues.
  • Tiny whitespace/gap around sliced images: images are inline-level by default and can leave baseline/whitespace gaps. Either make those images block-level or collapse the line box in the container. Two lightweight fixes are to set images to display:block or to set the parent container’s line-height/font-size to eliminate inline gaps.

Other notes: a global reset (suggested by ) helps, but a targeted approach (reset body margins to 0, center the wrapper with margin:auto, force sliced images to display:block) is often safer for an existing design. The meta compatibility trick mentioned by can be used as a temporary fallback, but it’s better to fix the markup/doctype so modern browsers render in standards mode. Use IE’s F12 developer tools to verify the document mode if something still looks off.

Useful references: MDN on Doctype/quirks mode, MDN on the map element, and the W3C Markup Validator.

Recommended Answers

All 4 Replies

Hi, I had a look at your page, W3C says you need a DOCTYPE declaration to identify the language being used. eg

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

Also it looks as if there are 2 div id #img_nav on your page. To have more than one ID of the same name on a page, Class id should be used.
Your code:
<div id="menu_nav_body">
<img id="img_nav" src="images/menu_nav_body.jpg" usemap="#img_nav" />

Perhaps change to:
<img src="images/menu_nav_body.jpg" usemap="#img_nav" />

You've used #img_nav in your html, but it is not referenced in your CSS code.
Admittedly I'm relatively new at this so I hope that I haven't gone charging in the wrong direction. Hope it all works out.

jaminit

The doctype fixed it.

Also it looks as if there are 2 div id #img_nav on your page. To have more than one ID of the same name on a page, Class id should be used.

This has to stay that way or else the image map does not work anymore. It don't make sense to me. But it has to stay that way.

Thanks for the reply ot was very helpful.

Regarding your muliple IDs, change the following:

<img id="img_nav" src="images/menu_nav_body.jpg" usemap="#img_nav_map" />
      <map id="img_nav_map">
        <area shape="rect" coords="30,10,196,35" href="home" alt="Home" title="Home" />
        <area shape="rect" coords="30,39,196,64" href="Login" alt="Login or Register" title="Login or Register" />
        <area shape="rect" coords="30,68,196,93" href="About" alt="About Us" title="About Us" />
        <area shape="rect" coords="30,101,196,126" href="Terms of Use" alt="Terms of Use" title="Terms of Use" />
        <area shape="rect" coords="30,130,196,155" href="Privacy Policy" alt="Privacy Policy" title="Privacy Policy" />
      </map>

That should sort it out. Now regarding the additional padding. Lets try reset all default broswer styling.

*
{
margin: 0;
padding: 0;
}

Try it out let me know if it worked

If it only doesn't work in ie8 and works well in ie7 I usually just put this lien of code in the head:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

so it emulates ie7 engine

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.