473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

CSS background-image error

Please could somebody help me feel like less of a complete idiot.
Following the advice of people who know what they're talking about, I have abandoned MS Front Page and MS Publisher and am trying to teach myself pure HTML and CSS.
Trouble is, I can't get past the following snag on my very first project.
I want to use an image I have as a background, but every time, Firefox 2.0.0.7 returns an error that says: "Error in parsing value for background-image. Declaration dropped."
The style sheet entry reads:

body { background-image: url ("images/lines.jpg"); }

The HTML entry in the head area reads:

<link href="style/style.css" type="text/css" rel="stylesheet" />

I've opened the image in Photoshop and it's a JPG in RGB, 8 bits per channel, and has worked previously on a website.
I've checked the file slug and file location and everything else I can think of, but I'm stumped.
Can anyone help?
Thanks
John Fuller
(Windows XP-SP2 / Firefox 2.0.0.7, Notepad as HTML editor)
Oct 16 '07 #1
7 20234
drhowarddrfine
7,435 Expert 4TB
Following the advice of people who know what they're talking about, I have abandoned MS Front Page and MS Publisher and am trying to teach myself pure HTML and CSS.
Proof that you're not an idiot. You followed good advice.
Firefox 2.0.0.7 returns an error
Firefox does? What are you using in Firefox to show this error?

There is nothing wrong with the markup you show and, if it's a jpg from Photoshop then I'm sure it's OK so we need to see the rest of the markup to determine the problem.
Oct 16 '07 #2
Death Slaught
1,137 1GB
Please could somebody help me feel like less of a complete idiot.
Following the advice of people who know what they're talking about, I have abandoned MS Front Page and MS Publisher and am trying to teach myself pure HTML and CSS.
Trouble is, I can't get past the following snag on my very first project.
I want to use an image I have as a background, but every time, Firefox 2.0.0.7 returns an error that says: "Error in parsing value for background-image. Declaration dropped."
The style sheet entry reads:

body { background-image: url ("images/lines.jpg"); }

The HTML entry in the head area reads:

<link href="style/style.css" type="text/css" rel="stylesheet" />

I've opened the image in Photoshop and it's a JPG in RGB, 8 bits per channel, and has worked previously on a website.
I've checked the file slug and file location and everything else I can think of, but I'm stumped.
Can anyone help?
Thanks
John Fuller
(Windows XP-SP2 / Firefox 2.0.0.7, Notepad as HTML editor)

This most likely wont help any, but could you post your entire markup, and put up the image as an attachment.

Thanks, Death
Oct 16 '07 #3
steven
143 100+
If your quoted code is accurate, the problem lies in the space between url and the parenthesis containing the url.

You have:
Expand|Select|Wrap|Line Numbers
  1. body { background-image: url ('foo.jpg'); }
You should have:
Expand|Select|Wrap|Line Numbers
  1. body { background-image: url('foo.jpg'); }
note the lack of whitespace between `url` and the parenthesis.
Oct 16 '07 #4
Death Slaught
1,137 1GB
If your quoted code is accurate, the problem lies in the space between url and the parenthesis containing the url.

You have:
Expand|Select|Wrap|Line Numbers
  1. body { background-image: url ('foo.jpg'); }
You should have:
Expand|Select|Wrap|Line Numbers
  1. body { background-image: url('foo.jpg'); }
note the lack of whitespace between `url` and the parenthesis.
HTML will truncate the spaces in your text. Any number of spaces count as one. Also a new line counts as one space. So it shouldn't make a difference wether he has spaces between his URL and the background-image attribute.


- Death
Oct 16 '07 #5
steven
143 100+
HTML will truncate the spaces in your text. Any number of spaces count as one. Also a new line counts as one space. So it shouldn't make a difference wether he has spaces between his URL and the background-image attribute.


- Death
CSS is not HTML. The browser will not truncate multiple spaces into a single space... or at least, firefox does not (whether the CSS is inline in the head of the document, or in an external file). Even if the browser truncated whitespace in CSS, which it doesn't... it would still only truncate to a single space and I'm saying that a single space is the cause of the issue. ;)

If his quote was indeed accurate, then that is the problem. Whitespace between 'url' and the parenthesis will cause the background image not to show. Removing the whitespace fixes the issue.

Steven =]
Oct 16 '07 #6
Death Slaught
1,137 1GB
CSS is not HTML. The browser will not truncate multiple spaces into a single space... or at least, firefox does not (whether the CSS is inline in the head of the document, or in an external file). Even if the browser truncated whitespace in CSS, which it doesn't... it would still only truncate to a single space and I'm saying that a single space is the cause of the issue. ;)

If his quote was indeed accurate, then that is the problem. Whitespace between 'url' and the parenthesis will cause the background image not to show. Removing the whitespace fixes the issue.

Steven =]
Nvm you were right congratz =p.........I did a little research and found this in bold:

Do NOT leave spaces between the property value and the units! If you use "margin-left: 20 px" instead of "margin-left: 20px" it will only work properly in IE6 but it will not work in Mozilla/Firefox or Netscape.

That's why it works on my comp if I add 100 spaces between them.

Thanks, Death

PS - Once again congratz on winning this time but don't get used to it lol...............
Oct 16 '07 #7
Steven, you have it right!
The space between "url" and the opening parenthesis for the image file name was the problem. As soon as I removed the space, the background appeared on my page.
Thanks to you, Steven, and also to drhowarddrfine and Death Slaught.
I hope some day I'll know enough to help you guys in return. But I doubt it.
All the best,
Struggler
Oct 25 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Stanimir Stamenkov | last post by:
Here are two cases regarding inline-level elements' line-height, padding and background, which I doesn't understand: <div style="background: black; color: white; line-height: 1.5">...
1
by: CMAR | last post by:
I have a design of a frameless page on my practice website: http://home.ne.rr.com/thespar/designerN.htm The idea is to have a #left navigation bar which is absolutely positioned and which...
8
by: Serge Hartmann | last post by:
hi there, I created two different backgrounds for the same page to obtain a (fake) left margin and a (true) right margin. -> left background, defined in body section, aligned bottom and with...
4
by: coolsti | last post by:
I have been playing around with this task for some hours now, and can't seem to find a way. I have an assortment of buttons on a web page, which have their background colors defined via style...
3
by: Peter Williams | last post by:
Hi All, I want to write some javascript for a html page which does the following. Imagine that the page contains a table with 2 columns and 3 rows, e.g.: +---+---+ | A | B | +---+---+
6
by: Francois Bonzon | last post by:
Any idea how I can launch a background task from a PHP script? For example, when a user posts on my message board, it may fire many e-mail notifications to other users, and other tasks. I want...
0
by: Jeb Hunter | last post by:
Well, how can I describe this succinctly? I have a page with DIVs that us background images to produce a border effect. It works perfectly well, but I want to make up (for now) 3 different...
2
by: darkpowrjd | last post by:
I've been trying to create a new navigation system for my site, and I got everything figured out except for one thing. Here is the CSS code I'm using right now: body { font: normal 10px Verdana,...
7
by: arupfrancis | last post by:
Hi, I am trying to create a colored box using background images. I am able to do it easily using tables but doing it in divs is proving to be an issue. Moreover IE and Mozilla also seems to be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.