homepage Welcome to WebmasterWorld Guest from 54.205.106.111
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderators: not2easy

CSS Forum

    
CSS - Can't seem to get the syle sheet working
cindy




msg:3777162
 11:45 pm on Oct 30, 2008 (gmt 0)

I am trying to learn how to use style elements and I seem to be stuck. I can't figure out why it is not working properly. Can anyone help, please? I hope this gets easier eventually ! Thanks!

<html>

<head>

<title> ? </title>

<style type="text/css">

</head>

body {
background-color: #C2A7F2;
font-family: sans-serif;
}
h1 {
color: #2A1959;
border-bottom: 2px solid #2A1959;
}
h2 {
color: #474B94;
font-size: 1.2em;
}
h2, p {
margin-left: 120 px;
}
</style>

<body>
<h1><img src="?.gif" alt="logo" /> ? </h1>

<h2>Text</h2>
<p>Text</p>

<h2>text</h2>
<p>text<em>text</em> text </p>

<h2>text</h2>
<p>text;text
text</p>
</body>

</html>

 

encyclo




msg:3777200
 12:56 am on Oct 31, 2008 (gmt 0)

<style type="text/css">

</head>

You have some invalid HTML which is the probable cause of the problem: the </head> tag needs to be placed after the </style> tag.

Note that you should really be adding a doctype to your page, for two reasons: the first is that having a doctype will allow you to validate your page and spot coding errors such as the above more easily. The second is that, for anything more than very basic CSS, the presence of a full doctype ensure the browser will follow the standards closely when parsing the page, making the behavior of the CSS much more consistent cross-browser.

The best doctype for you is probably this one:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

See also:

  • FAQ: Choosing the best doctype for your site [webmasterworld.com]
  • HTML validator [validator.w3.org]
  • CSS validator [jigsaw.w3.org]
  • cindy




    msg:3778829
     11:07 pm on Nov 2, 2008 (gmt 0)

    Thank you!

    Global Options:
     top home search open messages active posts  
     

    Home / Forums Index / Code, Content, and Presentation / CSS
    rss feed

    All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
    Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
    WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
    © Webmaster World 1996-2014 all rights reserved