Forum Moderators: not2easy

Message Too Old, No Replies

problem with external css file

I am not getting the correct display with external css file

         

alobi48235

4:01 pm on Apr 27, 2009 (gmt 0)

10+ Year Member



I am trying to get a better handle on display web content using css for layout but for some reason it is not displaying correctly when I use external css file but the same code will render perfectly when it is embedded in the fileb here are my files

Html file with external link
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Basic Two Culomn Layout with left Menue</TITLE>
<link rel="stylesheet" type="text/css" href="TwoColumnLeftMenuHeader.css"/>

</HEAD>

<BODY>
<div id="header''>
<p>Your header will go here. You can place images, text links, etc. in this div. To change
the properties of this div you can change the #header selector in the style sheet that is
located on this page between the head tags.</p>

</div><!---header--->
<div id="left">
<p>Menu</p>
<p>Menu</p>
<p>Menu</p>

</div>
<div id="center">
<p>All of your content goes in this div. This side is fluid so that if the window is collapsed,
your div will collapse also and fit the screen perfectly. To change the properties of this
div you can change the #content selector in the style sheet that is located on this page
between the head tags.</p>

</div><!-------Content--->

</BODY>
</HTML>

Here is my .css file
body
{ margin-top: 0;
margin-bottom: 0;
margin-left: 0;
margin-right: 0;
padding-left: 0;
padding-right: 0;
}

#header {
margin: 20px;
padding: 10px;
height: 100px;
}
#left {
position: absolute;
left: 15px;
top: 160px;
width: 200px;
}
#center {
top: 0;
margin-left: 230px;
margin-right: 15px;
}

swa66

8:14 pm on May 1, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld! [webmasterworld.com]

A few things:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">

HTML 3.2 is ancient, I'd suggest to update it to 4.01 (in your doctype), also use a full doctype to keep legacy IE versions out of quirks mode.

<link rel="stylesheet" type="text/css" href="TwoColumnLeftMenuHeader.css"/>

th eslash at the end eans this is xhtml (and not written i a wayto make it compatible with html parsers.
- To make xhtml compatible with html parsers: add a space in front of the slash
- To make it html: remove the self closing slash (or use a xhtml doctype, but then having everythign absolutely spot on and valid becomes even more important)

Your CSS can be written for more compact:


body
{ margin-top: 0;
margin-bottom: 0;
margin-left: 0;
margin-right: 0;
padding-left: 0;
padding-right: 0;
}

can be written as:

body {
margin: 0;
padding: 0;
}

Hope this helps you, also do try to validate your HTML and CSS.

alobi48235

2:00 pm on May 5, 2009 (gmt 0)

10+ Year Member



thanks for you help