Solved

body selector in linked css not recognized

Posted on 2002-05-13
22
400 Views
Last Modified: 2012-05-04
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
Comment
Question by:MHayes
  • 7
  • 6
  • 3
  • +4
22 Comments
 
LVL 12

Expert Comment

by:lexxwern
ID: 7008001
post the code...
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 7008382
We need to see code or a link to the page please.

Cd&
0
 
LVL 19

Expert Comment

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

Max.
0
 
LVL 12

Expert Comment

by:ahosang
ID: 7008672
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
 
LVL 18

Expert Comment

by:bruno
ID: 7008743
code!  code!  where's the code!
0
 
LVL 4

Expert Comment

by:Gibble
ID: 7011318
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 7011541
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
 
LVL 19

Expert Comment

by:DreamMaster
ID: 7011553
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
 

Author Comment

by:MHayes
ID: 7011557
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
 

Author Comment

by:MHayes
ID: 7011580
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 7011586
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 4

Expert Comment

by:Gibble
ID: 7011806
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
 
LVL 4

Expert Comment

by:Gibble
ID: 7011809
Oops, didn't mean to propose as answer :(
0
 

Author Comment

by:MHayes
ID: 7011833
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
 

Author Comment

by:MHayes
ID: 7011839
thanks, but it didn't work - please my next comment.
I appreciate your help.
0
 
LVL 4

Expert Comment

by:Gibble
ID: 7011844
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
 

Author Comment

by:MHayes
ID: 7011875
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
 
LVL 4

Accepted Solution

by:
Gibble earned 75 total points
ID: 7011881
get rid of <style> too
0
 

Author Comment

by:MHayes
ID: 7011882
Gibble:  please disregard previous comment.
0
 

Author Comment

by:MHayes
ID: 7011886
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
 
LVL 4

Expert Comment

by:Gibble
ID: 7011888
Not sure on that one as I never use it.
0
 
LVL 18

Expert Comment

by:bruno
ID: 7012063
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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Uploading files to the web server has become common part of almost any kind of web application. People use different technologies to solve this, but regardless of the technology used, it is always useful to have some kind of progress indicator shown…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now