Link to home
Start Free TrialLog in
Avatar of MHayes
MHayes

asked on

body selector in linked css not recognized

I'm stumped.  My linked CSS has all selectors working in the attached .htm pages, but for some reason I cannot get any properties associated with the BODY selector to be recognized.  I've triple-checked file/folder names, locations and my syntax, and I cannot find a reason for this. My graphics are fine as well.
Thoughts?

HERE IS THE CODE FOR THE STYLESHEET:
<html>
<head>
<title> stylesheet
</title>

BODY { background-image:url('/images/floralbg.jpg')
; background-attachment: fixed;
     }

P, UL, OL {
       text-align: justify;
       font-size: 14pt;
       font-color: navy;
       font-family: perpetua, arial, verdana;
       margin-left: 10%;
       margin-right: 10%;
      }

</head>
<body>
</body>
</html>

THANKS!
Avatar of lexxwern
lexxwern
Flag of Netherlands image

post the code...
We need to see code or a link to the page please.

Cd&
Avatar of DreamMaster
DreamMaster

Could simply be a : instead of a ; for all I'd be able to say like this without the code...

Max.
Obviously as everyone says, post the code or a link, but if your content is all inside various table cells(<td>), some browser versions(can't remember which exactly) won't cascade through to the td. If  that's the case, put td as selector as well.
<style>
body, td {color:blue}
</style>
code!  code!  where's the code!
You have pasted:
<html>
<head>
<title> stylesheet
</title>

BODY { background-image:url('/images/floralbg.jpg')
; background-attachment: fixed;
    }

P, UL, OL {
      text-align: justify;
      font-size: 14pt;
      font-color: navy;
      font-family: perpetua, arial, verdana;
      margin-left: 10%;
      margin-right: 10%;
     }

</head>
<body>
</body>
</html>

If this is your whatever.css file remove all the <> tags.  the css file should only have the css.  If you are trying to place the stylesheet in your html file, add the tags <style></style> around all your css (inside your <head> tags)
MHayes,

Please do not edit the question.  All you are doing is causing confusion.  Post new comments so that it is possible to follow what is going on in the thread.

Cd&
Either that which Gibble posted, or there is a problem with the way your code was formatted, or you are trying to get this to work in Netscape, and that won't work as netscape doesn't support the background-image style property....

Anyway, try to keep your code structurized and do yourself a BIG favor...something like this.

BODY
{
  background-image:url('/images/floralbg.jpg');
  background-attachment: fixed;
}

Max.

Avatar of MHayes

ASKER

I'm not clear about this answer.  Are you saying that I should have no <html>, <head>, etc. tags in the .css file at all?  With regard to the <style></style> tags, I already have <LINK REL="stylesheet" TYPE="text/css" HREF="CSS/stylesheet.css"> in the head section of the .htm pages and this is working for the other selectors on my .css page.  Are you saying I should add additional tags on the .htm pages?
thanks
Avatar of MHayes

ASKER

I'm not clear about this answer.  Are you saying that I should have no <html>, <head>, etc. tags in the .css file at all?  With regard to the <style></style> tags, I already have <LINK REL="stylesheet" TYPE="text/css" HREF="CSS/stylesheet.css"> in the head section of the .htm pages and this is working for the other selectors on my .css page.  Are you saying I should add additional tags on the .htm pages?
thanks
The problem with the body declaration is that there are quotes around the url.  That is incorect syntax, and the rest of the declaration will be ignored.  There is also a bug that occassionally shows up and causes the first declaration in a style sheet to be ignored.  The work around is to put a dummy class as the first entry.

The contents of the .css file should look like this:

<style>
.dummy {color:blue}
BODY { background-image:url(/images/floralbg.jpg)
; background-attachment: fixed;
}

P, UL, OL {
text-align: justify;
font-size: 14pt;
font-color: navy;
font-family: perpetua, arial, verdana;
margin-left: 10%;
margin-right: 10%;
}
</style>

The only other possibility I can think of is that it need sthe full path of the background image to find it.


Cd&
mhayes, that's correct, only CSS belongs in the .css file, NO HTML.

so your css file would only contain

BODY {
background-image:url('/images/floralbg.jpg');
background-attachment: fixed;
}

P, UL, OL {
text-align: justify;
font-size: 14pt;
font-color: navy;
font-family: perpetua, arial, verdana;
margin-left: 10%;
margin-right: 10%;
}

Oops, didn't mean to propose as answer :(
Avatar of MHayes

ASKER

Well, I took out all of the <> tags in the .css file and replaced with only <style> and </style>.  This caused all formatting for the other selectors which were already working to stop working in the .htm pages.  The only way to get the formatting for those previously working selectors back was to replace the original <>tags I had on the page and take out the <style></style> tags.  In addition, I have tried the url:(images/floralbg.jpg) with no quotes, with single quotes and with double quotes - none of these work.  I have put in the full path name and this doesn't work either.  I tried the .dummy selector first and it didn't work.  As an added bonus, I took out all reference to BODY selector in the .css document and that caused all other selectors to stop formatting in the .htm pages as well.    I am not using Netscape.

I appreciate everyone's help, but nothing at all seems to be working for this problem.  I welcome any other suggestions, but I guess I'm just going to have to give up and put the body background into each separate page.

thanks
Avatar of MHayes

ASKER

thanks, but it didn't work - please my next comment.
I appreciate your help.
get rid of the <style> tags in your .css file too
NO TAGS SHOULD BE IN YOUR .CSS FILE, NONE
no <html> (it's css not HTML), no <body>, no <head>, no <style> NONE!
Avatar of MHayes

ASKER

Dear Gibble:   I DID get rid of all tags except <style> in my .css file.  That caused ALL formatting in the .htm files to stop working.  The BODY selector still didn't work, and all of the other selectors that were working before stopped working.
ASKER CERTIFIED SOLUTION
Avatar of Gibble
Gibble

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MHayes

ASKER

Gibble:  please disregard previous comment.
Avatar of MHayes

ASKER

OK - taking the <style> tags out of .css worked to apply the image, but the background-attachment: fixed doesn't apply - do you know if this is specific to the fact that it is a .jpg and not a .gif?
thank you!  
Not sure on that one as I never use it.
jpg and gif should work just the same.


background-image is real quirky in different browsers.


http://www.blooberry.com/indexdot/css/properties/colorbg/bgimage.htm

http://www.blooberry.com/indexdot/css/syntax/units/url.htm



BRUNO