Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

body selector in linked css not recognized

Posted on 2002-05-13
22
412 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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
 
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 our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

839 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