• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 473
  • Last Modified:

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!
0
MHayes
Asked:
MHayes
  • 7
  • 6
  • 3
  • +4
1 Solution
 
lexxwernCommented:
post the code...
0
 
COBOLdinosaurCommented:
We need to see code or a link to the page please.

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

Max.
0
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

 
ahosangFinance Systems DeveloperCommented:
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>
0
 
brunoCommented:
code!  code!  where's the code!
0
 
GibbleCommented:
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)
0
 
COBOLdinosaurCommented:
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&
0
 
DreamMasterCommented:
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.

0
 
MHayesAuthor Commented:
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
0
 
MHayesAuthor Commented:
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
0
 
COBOLdinosaurCommented:
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&
0
 
GibbleCommented:
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%;
}

0
 
GibbleCommented:
Oops, didn't mean to propose as answer :(
0
 
MHayesAuthor Commented:
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
0
 
MHayesAuthor Commented:
thanks, but it didn't work - please my next comment.
I appreciate your help.
0
 
GibbleCommented:
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!
0
 
MHayesAuthor Commented:
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.
0
 
GibbleCommented:
get rid of <style> too
0
 
MHayesAuthor Commented:
Gibble:  please disregard previous comment.
0
 
MHayesAuthor Commented:
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!  
0
 
GibbleCommented:
Not sure on that one as I never use it.
0
 
brunoCommented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 7
  • 6
  • 3
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now