Forum Moderators: open

Message Too Old, No Replies

Browser Hell

         

hgerman

5:50 am on Oct 5, 2007 (gmt 0)

10+ Year Member



So I created this page that I'm happy with. Images in the background in tables, with CSS images super-imposed perfectly over them. In IE for PC everything looks fine. But whenever I view it in every other browser, the CSS image appears a bit higher on the page. Why is this happening?! And what do I do so that the CSS images appears in the same position for alll browsers? Help!

Marshall

8:03 am on Oct 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You will need to post relevant CSS and HTML to help find the answer.

Marshall

tedster

2:06 pm on Oct 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Most likely the difference is related to the DTD you are using and/or the differences between browsers for default amounts of margin and padding.

hgerman

7:01 pm on Oct 5, 2007 (gmt 0)

10+ Year Member



Below is the code. Each of these browsers interpret the code differently: IE for PC, FF for PC, IE for MAC, Netscape for MAC, Opera for MAC, Safari for MAC.

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css" media="screen">
body {font-family: Arial, Helvetica, sans-serif; color: #000; margin:0px; padding:0px;}

#Content {
position:absolute;
left:50%;
width:100px;
margin-top:-303px;
margin-left:15px;
text-align:left;
padding:5px;
line-height: 0.0em;
z-index:2
}

h1 {
font-size:12px
}

p {
font-size:10px
}
</style>
</head>

<body>
<table width="801" height="558" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#CCCCCC">&nbsp;</td>
<td bgcolor="#CCCCCC">&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td bgcolor="#CCCCCC">&nbsp;</td>
<td bgcolor="#CCCCCC">&nbsp;</td>
</tr>
<tr>
<td height="55" bgcolor="#CCCCCC">&nbsp;</td>
<td bgcolor="#CCCCCC">&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td bgcolor="#CCCCCC">&nbsp;</td>
<td>&nbsp;</td>
<td bgcolor="#CCCCCC">&nbsp;</td>
<td bgcolor="#CCCCCC">&nbsp;</td>
</tr>
<tr>
<td bgcolor="#CCCCCC">&nbsp;</td>
<td bgcolor="#CCCCCC">&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td bgcolor="#CCCCCC">&nbsp;</td>
<td bgcolor="#CCCCCC">&nbsp;</td>
</tr>
</table>
<div id="Content">
<h1>Gray Box</h1>
<p>Bla, bla, bla</p>
<p>Bla, bla, bla</p>
</div>
</body>
</html>

Marshall

7:10 pm on Oct 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What doctype are you using?

Marshall

hgerman

10:00 pm on Oct 5, 2007 (gmt 0)

10+ Year Member



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

penders

11:41 pm on Oct 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



In IE for PC everything looks fine.

But in the example you post, IE6 does not obey the height="55" on the middle row, which I assume is a requirement?

height is not actually a valid attribute on the TABLE element, despite browsers having supported it since the year dot. So you could try setting the height on the first TD in each row: 251, 55, 252 respt (Total=558) - this at least seems to make your example table consistent across browsers (Win: IE6, FF1.5, Op8) and should validate.

There are other issues however with your #Content DIV. And as tedster suggests this is certainly at least part due to browser differences in the default margins on H1 and P elements. Try setting margin:0 on both of these.

Also, watch the missing ';' on your last property values in each rule - as it caught me out! I'd always add a ';' at the end of each property value, so as to reduce the chances of error when you add more.

line-height:0.0em

You'll certainly want to increase the line-height once you've adjusted the above rules!

<edit> You'll probably want to change to an HTML DOCTYPE or at least add the appropriate XHTML attributes to your HTML element.

hgerman

2:16 pm on Oct 9, 2007 (gmt 0)

10+ Year Member



Very helpful! Thanks.