Solved

body background image

Posted on 2001-07-15
17
264 Views
Last Modified: 2010-05-18
Hi all:

This line will work if I put it directly on the page, but not if I use an external .css file.  Any idea why??

body {background-color: #CCFFFF; background-image: URL("images/Clouds.gif")}

Thanks!
0
Comment
Question by:ClassyLinks
[X]
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
  • 6
  • 5
  • 5
  • +1
17 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6283560

background-image: URL("images/Clouds.gif")

First get rid of hte quotes. The url in not supposed to be quoted.

However, it should work the same way whether it is in an external sheet or not; that says there is something else in the sheet causing the problem.

Post the sheet, and i will take a look.

Cd&

0
 
LVL 7

Author Comment

by:ClassyLinks
ID: 6283567
Thanks Cd...


All other elements of the style sheet work fine.  Only the background is giving me problems.  Removing the quotes has no effect.

Here is the sheet:

<style>

body {background-color: #CCFFFF; background-image: URL(images/Clouds.gif)}
A:hover {color: #FF0000; text-decoration:none}
A:link {text-decoration:none; color: #0000cc}
A:visited {text-decoration:none; color: #0000cc}
A:visited:hover {color: #FF0000; text-decoration:none}

</style>
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6283579
What browser are you using?

Have you tried it in different browsers?

What about specifying the image before the colour?

:o\

Ant
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 15

Expert Comment

by:a.marsh
ID: 6283582
Just wondering - does the browser look for the image relative to the location of the stylesheet file or the HTML file in which the stylesheet is used?

Perhaps that is the issue - are the stylesheet file and the HTML file in the same directory?

Ant
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6283585
Of course - my last comment is correct!

I've setup a test html file and a background image - both are in the same directory.

Now I've created a sub-directory and placed the stylesheet there.

I'm using IE5 and it looks for the background image relative to the location of the stylesheet, NOT the location of the HTML being viewed.

Well I've learned something new today!

Ant
0
 

Expert Comment

by:Leath
ID: 6283590
Have you tried writing "URL" in small letters?
I mean:

body {background-color: #CCFFFF; background-image: url("images/Clouds.gif")}

I used it this way... with small letters and quotation marks and it works fine...


Leath #-|
0
 
LVL 7

Author Comment

by:ClassyLinks
ID: 6283593
No luck there ant....I already had it in relation to the stylesheet.

leath:  capitals make no difference.

IE5.5

Removing background color makes no difference, specifying image before colour....no difference.


HMMM...strange eh?
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 50 total points
ID: 6283597
I have sometimes seen a parsing problem in IE4 and IE5 where it loses the first line. The workaround is to stick in a dummy declaration:

<style>
.dummy {color:blue}
body {background-color: #CCFFFF; background-image: URL(images/Clouds.gif)}
A:hover {color: #FF0000; text-decoration:none}
A:link {text-decoration:none; color: #0000cc}
A:visited {text-decoration:none; color: #0000cc}
A:visited:hover {color: #FF0000; text-decoration:none}

</style>

Not guaranteed.

Cd&
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6283602
BTW for forward compatibility URL should be lower case XHTML is case sensitive, and all attributes and tags are supposed to be lower case. Use of quotes is non-standard, and not supposrted by all browsers.

Cd&
0
 
LVL 7

Author Comment

by:ClassyLinks
ID: 6283610
Ok...Cd, thanks.


Have changed everything to lower case.  No quotes.  Still no luck.

Any ideas?

BTW - It's not even showing the background-color.  So it is not only a problem with the background-image, but likely with the whole line.
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6283611
I agree on "url" being lowercase... but XHTML has nothing to do with the stylesheet parameters does it? Hence the W3C has an XHTML validator and then a CSS validator.

I must admit that I'm a little puzzled then - is the site on the Web so we could look at it ClassyLinks?

:o)

Ant
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6283614
LOL.  I got curious about resolving the path; so I looked it up.  The standard is to resolve relative urls using the style sheet location.  IE does it that way, but Netscrap uses the HTML page location.  

I learned something too.  

Cd&
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6283615
Ahhh! Are you sure it is finding the stylesheet file then ClassyLinks?

Could we see the <link> tag you are using?

A common problem is using:

src="style.css"

and not

href="style.css"


:o)

Ant
0
 
LVL 7

Author Comment

by:ClassyLinks
ID: 6283616
Holy Cow...how am I ever going to get the hang of this???

Thanks all!
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6283618
Did you add the dummy declaration to the external stylesheet file then and it worked?

Ant
0
 
LVL 7

Author Comment

by:ClassyLinks
ID: 6283633
yup...sorry I wasn't more clear about that.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6283642
Strange isn't it.  It does not seem to be documented anywhere and it does not happen consistently on all browsers even when they are the same build.  Has to be something to do with local settings I think.  So I just stick in the dummy on on my external sheets.

Thanks for the A. :^)

Ant,

The XHTML validator should be validating the styles as well but what it returns may depend on the DTD.  I rarily validate, so?...

Cd&
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…
Suggested Courses

617 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