/    Sign up×
Community /Pin to ProfileBookmark

Rrgghhh! Why?

Please run my code in IE and firefox. When i run it in firefox, it is perfect, but when i run it in IE the right hand section seems to expand a little. Can you please tell me how i could stop this. [COLOR=DarkGreen]SHOULD i use a table instad of DIVs.[/COLOR]

[SIZE=3]HERE IS THE HTML[/SIZE]

[COLOR=Blue]<html xmlns=”http://www.w3.org/1999/xhtml” lang=”en-US”>

<head>
<title>Two Column Fixed Width Layout</title>
<link rel=”stylesheet” href=”mystyle.css”>
<meta http-equiv=”Content-type” content=”text/html; charset=iso-8859-1″ />
</head>

<body>

<div id=”container”>

<div id=”header”> <!–HEADER–>
<p>banner<p>
</div>

<div id=”left”> <!–LEFT–>
<p>Left</p>
<p>Left</p>
<p>Left</p>
<p>Left</p>
<p>Left</p>
<p>Left</p>
<p>Left</p>
</div>

<div id=”right”> <!–RIGHT–>
<p>Right</p>
<p>Right</p>
<p>Right</p>
<p>Right</p>
<p>Right</p>
<p>Right</p>
<p>Right</p>
</div>

<div id=”footer”> <!–FOOTER–>
<p>Footer</p>
</div>

</div> <!– CONTAINERS CLOSING TAGS –>

</body>

</html>
[/COLOR]

[SIZE=3]HERE IS THE EXTERNAL STYLE SHEET[/SIZE]

[COLOR=Red]body {
text-align: center; /* this aligns the body content to the center of the page */
}

#container { /* the body consists of a container – everything is inside the container */
text-align: left; /* this aligns the content of the container to the left */
margin: 0 auto; /* 0 for top and bottom, auto for left and right – this centers the page content */
width: 780px; /* width is set to 780px */
}

#header {
border: 1px solid black; /* this creates a solid border around the div */
margin: 20px; /* this creates 20px space around the header*/
padding: 20px; /* this creates 20px space between the content and the border */
}

#left {
border: 1px solid black; /* this creates a solid border around the div */
width: 318px; /* width is set to 310 */
margin-left: 20px; /* this creates a 20 px space around the left of the div */
float: left; /* this floats the div to the left */
display: inline; /* div will be displayed inline*/
padding: 20px; /* this creates 20px space between the content and the border */
}

#right {
border: 1px solid black; /* this creates a solid border around the div */
margin-left: 382px; /* this creates a 392px space around the left of the div */
margin-right: 20px; /* this creates a 20px space around the right of the div */
padding: 20px; /* this creates 20px space between the content and the border */
}

#footer {
border: 1px solid black; /* this creates a solid border around the div */
margin: 20px 20px 0px 20px; /* top, right, bottom, left – spaces around the div*/
padding: 20px; /* this creates 20px space between the content and the border */
clear: left; /* this keeps the footer to the bottom incase the left becomes longer than the right area */
}

[/COLOR]

to post a comment
CSS

12 Comments(s)

Copy linkTweet thisAlerts:
@pauladkins1974Oct 24.2006 — Hello mate

It's actually the left getting smaller, not 100% sure why but this fixes the width.
[CODE]
#left {
border: 1px solid black; /* this creates a solid border around the div */
width: 318px; /* width is set to 310 */
_width: 360px; /* IE hack */
margin-left: 20px; /* this creates a 20 px space around the left of the div */
float: left; /* this floats the div to the left */
display: inline; /* div will be displayed inline*/
padding: 20px; /* this creates 20px space between the content and the border */
}[/CODE]


This doesn't fix the height but this will be dictated by content anyway.

Basically I've increased the width for IE by the padding and border width, adding _ means firefox ignores the code.

I [U]think[/U] it may have something to do with float.

Anyway hope this helps.

Cheers

Paul
Copy linkTweet thisAlerts:
@oo7mlauthorOct 24.2006 — Fair play to you, thanks, do you know anyother way that i could get left and right to show up ok, without the use of tables. thanks again
Copy linkTweet thisAlerts:
@pauladkins1974Oct 24.2006 — Hello again

You should be OK as you are but for further help check out this site, it has a load of free css layouts.

[URL=http://www.maxdesign.com.au/presentation/page_layouts/]Max Design[/URL]

I don't know if they have a 2 column with footer but just add your existing footer code to one if not.

Hope this helps.

Cheers

Paul
Copy linkTweet thisAlerts:
@oo7mlauthorOct 24.2006 — cheers
Copy linkTweet thisAlerts:
@abzOct 24.2006 — does your html have a <!DOCTYPE in the real version? if not, it should

abi
Copy linkTweet thisAlerts:
@oo7mlauthorOct 24.2006 — No, what should it have, can you tell me exactly what should be in the <!DOCTYPE please. Sorry i haven't got the best knowledge of css
Copy linkTweet thisAlerts:
@KorOct 24.2006 — Either you float the div left or you make the div an inline displayed element (but an inline element can not have a margin, only a padding...). For instance a DIV is a block displayed element by default, and a SPAN is an inline element by default. They act different to some CSS attributes like [I]margin[/I], [I]float[/I].....
Copy linkTweet thisAlerts:
@oo7mlauthorOct 24.2006 — Ok but how does that fix my problem
Copy linkTweet thisAlerts:
@drhowarddrfineOct 24.2006 — New pages should always use a strict doctype:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Without one, you are now in quirks mode.
Copy linkTweet thisAlerts:
@oo7mlauthorOct 25.2006 — Ok thanks, but it didn't fix my problem, thanks for your help anyway, thanks for trying
Copy linkTweet thisAlerts:
@xgravity23Oct 26.2006 — Adding a DOCTYPE! helps browsers to know HOW to display the code, so you might not have noticed a difference, but perhaps some users might. "Quirks mode" basically means that some browsers are just going to try to display the code as best as they can, but it might not look the way you want it. Using XHTML 1.0 STRICT code means that your page will render correctly in most standards-compliant current (and probably future) browsers! To make sure you [I]are[/I] using XHTML 1.0 STRICT, you can run your code through [URL=http://validator.w3.org/]this validator[/URL].

And "XHTML 1.0 STRICT" requires you to close *every* tag, so you should add a " />" to the end of your <link> tag in the header. ?
Copy linkTweet thisAlerts:
@KorOct 26.2006 — I bet that even a HTML strict doctype will be used succesfully many years from now...
×

Success!

Help @oo7ml spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...