background color in CSS ignored

User 1963956 Photo


Registered User
17 posts

Hi,
I'm sure this is a simple error, but I can't figure out what I'm doing wrong :/. I want to be able to change the background color of my pages by using the css style sheet.
My problem is that I can pick up the background color for my page if I put the code directly into each page, as follows:
=====================================================
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- Created with the CoffeeCup HTML Editor 2008 -->
<!-- http://www.coffeecup.com/ -->
<!-- Brewed on 13/08/2009 16:10:31 -->
<head>
<style>
body{background-color:#FFFFD8;}
</style>

<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<meta name="generator" content="CoffeeCup HTML Editor 2008 - www.coffeecup.com"/>
<link rel="stylesheet" type="text/css" href="css/NFC_main.css"/>
=================================================

However, this defeats the purpose of the css. If I take the style tag info out, and put the style into the css (NFC_main.css) as folows, the color is not picked up:

==================================================
<!-- Style Sheet created with the CoffeeCup StyleSheet Maker -->
<!-- http://www.coffeecup.com -->
<style type="text/css">
<!--Body
{background-color:#FFFFD8;}

div.wrapper {
margin-left : 10%;
margin-right : 10%;
}
H1 {
font-family: Papyrus,Palatino Linotype,Georgia,serif;
font-size: 22px;
font-weight: 700;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #80A82B;
text-align: center;
}
=================================================

Everything else I can control centrally from the css. Can anyone explain what I'm doing wrong with the background color tag in the css? I have searched the internet and this site and this seems to be the correct syntax.

My site is http://www.nikkifieldconsulting.com
I'm using HTML Editor version 12 build 412 (registered) on Windows 7

Thanks for any help.
User 187934 Photo


Senior Advisor
20,267 posts

Change this
<!--Body

to this
body

And drop this.
<style type="text/css">
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 1963956 Photo


Registered User
17 posts

Thanks for your reply.
Tried your suggestion (I had tried dropping the prefix to the body tag before) but still no luck. The only way I can get the test page to work with the css as regards background color is to remove the doctype declaration.
My css now begins as follows:
=======================================================
<!-- Style Sheet created with the CoffeeCup StyleSheet Maker -->
<!-- http://www.coffeecup.com -->

body
{background-color:#FFFFD8;}


div.wrapper {
margin-left : 10%;
margin-right : 10%;
}
====================================================
Anything else I can try?
User 187934 Photo


Senior Advisor
20,267 posts

Is this css a style sheet?
if so try this.
<link rel="stylesheet" type="text/css" href="css/NFC_main.css" media="screen">
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 1963956 Photo


Registered User
17 posts

Thanks again for responding. I'm in a different timezone from you (Europe), hence the delay in getting back to you.
Forgive my ignorance, but I thought that all css(es) were style sheets, so I'm not sure what you mean by your question. I already have the text you suggest in my page header, so unfortunately that hasn't made a difference.
I suppose the good thing is that I can solve this problem by putting the style info in each page, but that seems very clunky, and I'd love to know what I'm doing wrong in the style sheet.
I'm updating an old site that I created several years ago, and I'm just duplicating page header content from the old site when I create new pages, so perhaps I'm using outdated header text. I'll look into that.

Meanwhile, if you have any other thoughts or suggestions I'd be grateful :).
User 187934 Photo


Senior Advisor
20,267 posts

Can I have a link to the actual page your working on?:)
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2073552 Photo


Registered User
1,625 posts

Add body { background-color: #FFFFEC; } to your menu.css and it works. :P
"An Apple doth not fall far from its tree, yet an orange does."

https://lbwebsitedesign.com - Responsive Web Design & Web Hosting Services.
http://helpsite.sirage.com - HTML5, CSS3 and CC Help Video Blog.
User 38401 Photo


Senior Advisor
10,951 posts

Take all of this out of the top for starters:

<!-- Style Sheet created with the CoffeeCup StyleSheet Maker -->
<!-- http://www.coffeecup.com -->
<style type="text/css">
<!--

Now remove this from the bottom:

-->
</style>



The style sheet doesn't read the above information as CSS styles at all and the comments using the arrows and dashes are not recognized as comments in CSS, a CSS comment (tags to tell the browser to ignore something) looks like this, but is not needed here, just delete the above and save it:

/* text here that explains whatever you want to explain */

The information I say to delete is created for HTML Editor, not for a separate CSS file so it does not get carried over. Delete it from the CSS and from the HTML file also.

This should fix your file up and make it work right :)
User 2073552 Photo


Registered User
1,625 posts

Liz,

I found your problem... This is what your CSS should be... Nothing more, nothing less... (Unless you add more... lol

body {background-color: #FFFFD8; }

div.wrapper {
margin-left : 10%;
margin-right : 10%;
}

H1 {
font-family: Papyrus, Consolas, Sans-serif;
font-size: 22px;
font-weight: 700;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #80A82B;
text-align: center;
}
H2 {
font-family: Papyrus, Consolas, Sans-serif;
font-size: 20px;
font-weight: 700;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #80A82B;
text-align: center;
}
.caption {
font-family: Papyrus, Consolas, Sans-serif;
font-size: 22px;
font-weight: 700;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #80A82B;
text-align: center;
}
.presstext1 {
font-family: Papyrus, Sans-serif;
font-size: 12px;
font-weight: 900;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #80A82B;
margin-left: 200px;
margin-top: 160px;
}
#signature {
margin-left: 500px;
margin-top: 20px;
font-family: Mistral, Cursive;
font-size: 30px;
font-weight: 1000;
color: #80A82B;
}
#banner {margin-left: 0px; margin-top: 0px; width: auto;}
.firstpic {
margin-left: 50px;
margin-top: 50px;
}
.firstpicnews {
margin-left: 50px;
margin-top: 100px;
}
.followsamepara {
margin-left: 10px;
margin-top: 50px;
}
.followpic {
margin-left: 250px;
margin-top: 50px;
}
.followpic2 {
margin-left: 250px;
margin-top: -50px;
}
.rightpic1 {
margin-left: 500px;
margin-top: -100px;
}
.rightpic2 {
margin-left: 800px;
margin-top: -50px;
}
#presspic1 {
margin-left: 60px;
margin-top: 150px;
}
.presspictxt {
font-family: Papyrus, Sans-serif;
font-size: 12px;
font-weight: 900;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #877A47;
}
#presspictxt1 {
margin-left: 300px;
margin-top: 180px;
font-family: Papyrus, Sans-serif;
font-size: 18px;
font-weight: 900;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #877A47;
}
#presspic2 {
margin-left: 20px;
margin-top: 150px;
}
#presspictxt2 {
margin-left: 440px;
margin-top: -30px;
font-family: Papyrus, Sans-serif;
font-size: 12px;
font-weight: 900;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #80A82B;
}
#presspic3 {
margin-left: 30px;
margin-top: 150px;
}
#presspictxt3 {
margin-left: 570px;
margin-top: -30px;
font-family: Papyrus, Sans-serif;
font-size: 12px;
font-weight: 900;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #80A82B;
}

.pressfollowpic {
margin-left: 225px;
}
.horizrule {
margin-left:250px;
margin-right: 80px;
margin-top: 10%;
color: #80A82B;
}

.horizrule1 {
margin-left:250px;
margin-right: 80px;
margin-top: 5%;
color: #80A82B;
}

.horizrule2 {
margin-left:250px;
margin-right: 80px;
margin-top: 15%;
color: #80A82B;
}
.horizrule3 {
margin-left:250px;
margin-right: 80px;
margin-top: 10%;
color: #80A82B;
}
.horizrulesmall {
margin-left:600px;
margin-right: 200px;
margin-top: 8%;
margin-bottom: 0%;
color: #80A82B;
}
.horizrulesmall2 {
margin-left:600px;
margin-right: 200px;
margin-top: 1%;
margin-bottom: 0%;
color: #80A82B;
}
#title {
margin-left: 630px;
margin-top: -260px;
font-family: Papyrus, Sans-serif;
font-size: 30px;
font-weight: 900;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #80A82B;
}

#title2 {
margin-left: 630px;
margin-top: 40px;
font-family: Papyrus, Sans-serif;
font-size: 30px;
font-weight: 900;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #80A82B;
}
#titlepress {

margin-left: 630px;
margin-top: 50px;
font-family: Papyrus, Sans-serif;
font-size: 30px;
font-weight: 900;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #80A82B;
}
#titlecontact {
margin-left: 630px;
margin-top: 100px;
font-family: Papyrus, Sans-serif;
font-size: 30px;
font-weight: 900;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #80A82B;
}

#form {
margin-left: 50px;
margin-top: 0px; }

#newsevents {
margin-left: 630px;
margin-top: -300px;
font-family: Papyrus, Sans-serif;
font-size: 30px;
font-weight: 900;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #80A82B;
}
.sidemenu {
margin-left: 630px;
margin-top: -260px;
font-family: Papyrus, Sans-serif;
font-size: 30px;
font-weight: 900;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #80A82B;
}

.blurb {
margin-left: 500px;
margin-right: 80px;
margin-top: 80px;
font-family: Verdana, Sans-serif;
font-size: 14px;
font-weight: 500;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #877A47;
}

.pressblurb {

font-family: Papyrus, Sans-serif;
font-size: 18px;
font-weight: 500;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #877A47;
}
.pressblurbcont {

font-family: Papyrus, Sans-serif;
font-size: 18px;
font-weight: 500;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #877A47;
}
.textcont {
margin-left: 500px;
margin-right: 80px;
margin-top: 0px;
font-family: Verdana, Sans-serif;
font-size: 14px;
font-weight: 500;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #877A47;
}
.textcontpic {
margin-left: 500px;
margin-right: 80px;
margin-top: -50px;
font-family: Verdana, Sans-serif;
font-size: 14px;
font-weight: 500;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #877A47;
}
.textcontpic2 {
margin-left: 500px;
margin-right: 80px;
margin-top: 50px;
font-family: Verdana, Sans-serif;
font-size: 14px;
font-weight: 500;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #877A47;
}
.textcontpic3 {
margin-left: 500px;
margin-right: 80px;
margin-top: -150px;
font-family: Verdana, Sans-serif;
font-size: 14px;
font-weight: 500;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #877A47;
}
.textcontpic4 {
margin-left: 500px;
margin-right: 80px;
margin-top: -200px;
font-family: Verdana, Sans-serif;
font-size: 14px;
font-weight: 500;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #877A47;
}
.tabletxtpress {
font-family: Papyrus, Sans-serif;
font-size: 12px;
font-weight: 900;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #80A82B;
}
.newstexttrans {
margin-left: 630px;
margin-top: -230px;
font-family: Papyrus, Sans-serif;
font-size: 20px;
font-weight: 900;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #FFFFEC;
}

a:link {
color: #80A82B;
text-decoration: none;
}
a:visited {
color: #80A82B;
text-decoration: none;
}
a:hover {
text-decoration: none;
color: #C3419A;
}
a:active {
color: #FFCC00;
text-decoration: none;
}
.links {
font-family: Papyrus, Sans-serif;
font-size: 12px;
font-weight: 900;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #80A82B;
}
.list {
margin-left: 530px;
margin-right: 80px;
font-family: Verdana, Sans-serif;
font-size: 14px;
font-weight: 500;
font-style: normal;
text-decoration: none;
text-transform: none;
font-variant: normal;
color: #877A47;
}

#tablefoot {
margin-left: 25%;
margin-top: 15%;
}
#tablefoot2 {
margin-left: 25%; margin-top: 5%;
}
#tablemainpress {
margin-left: 350px; margin-top: -35px;
}


#tablefootpress {
margin-left: 25%; margin-top: 80%;
}
"An Apple doth not fall far from its tree, yet an orange does."

https://lbwebsitedesign.com - Responsive Web Design & Web Hosting Services.
http://helpsite.sirage.com - HTML5, CSS3 and CC Help Video Blog.
User 1963956 Photo


Registered User
17 posts

It's working!!
Thanks so much Rolly, Jo Ann & SirAge for persisting with this. Clearly I didn't properly understand how the css worked or what should be in there. I have now got some books to study up on it because I'm going to be doing a lot more of this work in the coming months.

I'm very grateful for your help. Have a great day in the US (for whatever remains of it). I'm off to bed here in France a happy woman, and hoping not to be dreaming of HTML all night again :).


Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.