473,795 Members | 2,452 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Background URL property in different browsers.

Gaz
Hi,

I have found an issue when comparing Firefox with IE6 (Windows) where
a page links to a css file that is in it's own directory. IE6 URL
property of the background css element uses the location of the css
file as the root when looking for the background image. Firefox uses
the location of the page that links the css as the root for the
background image.

This css will work for Firefox :
body
{
background:whit e url('Images/background test.gif') bottom right
no-repeat fixed; /*firefox works*/
}

And this css works for IE.

body
{
background:whit e url('../Images/background test.gif') bottom right
no-repeat fixed; /*IE6 works*/
}

Is this just one of those things? It would be nice to know which
browser is doing it right though.
thanks for any help..

ps : Here's the page :

<html>
<head>
<title> New Document </title>
<link href="css\test. css" type="text/css" rel="stylesheet ">
</head>

<body>

This is a test to see if different browsers mess up the background url
in the css when the css and the backgroun image are in different
folders than the css file

</body>

</html>
Jul 20 '05 #1
5 16299
Gaz wrote:
I have found an issue when comparing Firefox with IE6 (Windows) where
a page links to a css file that is in it's own directory.
"Its", not "it's".

http://homepages.paradise.net.nz/mat...nglish_02.html

Er... sorry - I got distracted.

Yes, you're right, this is an issue. The CSS1 spec says: "Partial URLs
are interpreted relative to the source of the style sheet, not relative
to the document"

(http://www.w3.org/TR/REC-CSS1#url)

As you may have guessed, IE gets it wrong and Firefox gets it right.
<link href="css\test. css" type="text/css" rel="stylesheet ">


Don't use backslashes in directory paths in HTML or CSS.

--
Mark.
http://tranchant.plus.com/
Jul 20 '05 #2
oo******@yahoo. co.uk (Gaz) wrote in message news:<76******* *************** ****@posting.go ogle.com>...
This css will work for Firefox :
body
{
background:whit e url('Images/background test.gif') bottom right
no-repeat fixed; /*firefox works*/
}

And this css works for IE.

body
{
background:whit e url('../Images/background test.gif') bottom right
no-repeat fixed; /*IE6 works*/
}

Is this just one of those things? It would be nice to know which
browser is doing it right though.


I don't know if there's a way around it, but it looks like IE is the
one doing it right:

For CSS style sheets, the base URI is that of the style sheet, not
that of the source document.

Source: http://www.w3.org/TR/REC-CSS2/syndata.html#x48
Jul 20 '05 #3
Gaz
Thanks, there are two workarounds I can think of.

1) Put css files in the same directory as the source. Not good if you
want to centralize your css files.

2) Put background/list style/etc.. images in the css directory, which
feels semi-natural I suppose since they are directly linked to style.

Of course this is only the tip of the iceberg when it comes to cross
-browser differences in rendering css. Isn't it feasible to centralize
a browsing rendering engine and for all browsers to use it? Like Open
GL or other cross-system APIs. Rendering is only one element of a
browser so the bigger browsers would lose none of their other features
if they did this. This would solve all this stupidity with different
companies doing different things with something that should be the
same!!!

Let's start a petition. Perhaps in 2016 it might all be sorted out.
I don't know if there's a way around it, but it looks like IE is the
one doing it right:

For CSS style sheets, the base URI is that of the style sheet, not
that of the source document.

Jul 20 '05 #4
Gaz
Meant this :

2) Put background/list style/etc.. images in the css *and* the source directory...
Not this :
2) Put background/list style/etc.. images in the css directory, which

feels semi-natural I suppose since they are directly linked to style.
Jul 20 '05 #5
Mark Tranchant wrote:
As you may have guessed, IE gets it wrong and Firefox gets it right.


Oops - this was just my natural assumption. It's the other way around.

The workaround is to use absolute references from the root of the web space:

background-image: url(/images/bg.jpg);

--
Mark.
Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2017
by: Billy | last post by:
Hello, I'm having a problem dynamically changing the color of a table background. I'm not sure exactly how to word this, but I'll give an example. I have a function called greentored(propname) i want to be able to change the following to a different color: document.all.propname.style.visibility
7
14960
by: miked | last post by:
Hi, On a webpage I'm authoring I'm having a problem with setting the text background colour. I'm using this: P {color ="FFFFFF"; background-color:"000000"; font-size:10pt; font-family: verdana, courier, monospace} with this:
25
12945
by: Neal | last post by:
According to the CSS lint at http://htmlhelp.org/tools/csscheck/, "The shorthand background property is more widely supported than background-color." Can anyone point me to, or provide, information on what browsers have difficulty with the non-shortcut methods of setting background properties?
11
3206
by: Konrad Den Ende | last post by:
I have a function returning a string but the problem is that the color of it is blue which suits me well for some pages but not for others. Is it possible to "feel" what the color of the background in the current document is and set the color of the output accordingly? The background will be an image, in most cases. -- Kindly Konrad
5
11098
by: proximus | last post by:
Hi, I am trying to change the background of table TD's. The problem is that I have no access to the HTML code. SO I am trying to alter this using Javascript/DOM in an external .js file. I have tried lot's of things and spent hours on this, I thought I might give it a try here. One of the TD's uses HTML to set the background, the other one uses CSS styling:
13
3971
by: Giggle Girl | last post by:
Hi there, I need to use a background image in a TR that does NOT restart everytime it hits a TD. Can it be done? Specifically, if you set a background image for an entier table, now mater how many TRs and TDs you have, it will show the complete/unfragmented image (as long as you don't over-ride it). When I set a TR background image, every time I hit a TD it "re-seeds" the image. I want to have a TR that shows an 800px image in it's
4
2470
by: bissatch | last post by:
Hi, I have launched my new website and having viewing it on the Mac Internet Explorer, have found that it isnt displaying my background-image property. Is this a common bug / occurance? How are background-image properties displayed on the Mac IE? Cheers Burnsy
2
22070
by: Mark | last post by:
IE creates an object of every ID'd HTML tag (so it appears), and each object sets a property for any parameter I set in the tag. For example, my HTML might be: <td id='cell1' background='myimg.jpg' width='30'... </tdwhich IE will use to create a Javascript object called 'cell1' with properties of background and width, like so: cell1.background would have a value of 'myimg.jpg' and cell1.width would have a value of 30. I can change the...
19
3991
by: david.karr | last post by:
If in my CSS I set the "background-color" property on the "body" element, it only covers the background of the elements defined in the body, up to the current width and height of the page. However, if the current component set has a resulting small height, this leaves most of the page with the original background color (white). However, if I set the property on the "html" element instead, it does color the entire visible page, beyond the...
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10437
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10214
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10164
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9042
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.