473,734 Members | 2,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why is it important that I define background-color for validated CSS

Hi,

I am running a w3c CSS validation check on a site in development. I
have many errors saying that my CSS is not valid because I have not
defined the background-color but instead left it default transparent.
Why does it require that every CSS defined element have their
background-color defined?

Also, when I set styles in the following way:

#div {
background: #FFF url('images/bg.gif');
}

....it still gives me an error saying that I havent defined
background-color. Is the above an invalid way of writting it?

Thanks

Burnsy

Feb 7 '06 #1
2 2859

bissa...@yahoo. co.uk wrote:

I am running a w3c CSS validation check on a site in development. I
have many errors saying that my CSS is not valid because I have not
defined the background-color but instead left it default transparent.
Warnings, not errors.
Why does it require that every CSS defined element have their
background-color defined?
Imagine the following author stylesheet:

body {color: black; background: white}
p {color: blue; background: transparent;}

and the user stylesheet
body {color: white !important; background: black !important;}

In that case the paragraphs will have blue text on a black background
(yuck). If the author had specifed
p {color: blue; background: white;}
then it would be okay.

Now, this is a problem when background images are used as due to tiling
you don't want to respecify them for every element.

In general, few people use user stylesheets and those that do are
usually savvy enough to write them carefully (e.g. liberal use of the
universal selector * helps) and use browsers or browser extensions that
let them toggle either the author or user css off entirely when
problems crop up.

So this is an issue that you should be aware of and which you should
think about, but it is only a warning not an error, so consider
yourself warned and if you want to carry on regardless, do so.
Also, when I set styles in the following way:

#div {
#div? Is 'div' really a useful unique identifer?
background: #FFF url('images/bg.gif');
}

...it still gives me an error saying that I havent defined
background-color. Is the above an invalid way of writting it?


I can't reproduce that error/warning with my stylesheet that contains
the line
body { background: #91C4D9 url("bg-blue.gif") fixed; color: #000;}
Can you post the URL of your stylesheet so other people can validate
it?

Steve

Feb 7 '06 #2
<bi******@yahoo .co.uk> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. .
Hi,

I am running a w3c CSS validation check on a site in development. I
have many errors saying that my CSS is not valid because I have not
defined the background-color but instead left it default transparent.
Why does it require that every CSS defined element have their
background-color defined?
If you set one colour then set them all. If you don't then it isn't a
validation error, just bad practice.

If my browser was set to display white text on a black background and I
visited a site where the text was set to black and the background colour
hadn't been set then the page would be black text on a black background.
Also, when I set styles in the following way:

#div {
background: #FFF url('images/bg.gif');
}

...it still gives me an error saying that I havent defined
background-color. Is the above an invalid way of writting it?


If I feed your CSS snippet through the W3C CSS validator then it comes up
with this message: "Line : 1 (Level : 1) You have no color with your
background-color : #div"

The background colour *has* been set but you haven't set any foreground
colour.
eg: #div {background: #FFF url('images/bg.gif'); color:#000000}
Feb 7 '06 #3

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

Similar topics

2
10476
by: Markus Mohr | last post by:
Hi, everyone, I have a special problem: For every monitor resolution in 200 pixel steps from 800 to 1600 pixels I have an image to be shown as centered background-image. Those images all have the same name and reside in the following physical path structure:
4
9734
by: Mimo Zus | last post by:
I'm hoping that someone can explain what's going on; better yet provide a workaround. I'm designing a centered CSS site based on a 550 pixel wide vertical background image. Onto this background I built a two column layout with nested navigation and content divs. The background image is centered via "background: ... center;", the divs are centered over it via "margin: 0 auto 0 auto;". The problem I'm having in IE6 is inconsistent...
11
3649
by: Jürgen Hochwald | last post by:
Hi Maybe this is a simple question, but I don't know how to solve. Background: A weather station connected to the serial port sends data packets. This data packets are containing variables fom one byte up to 4 byted in mixed order. Now I want to define a structure to overlay it with UNION over the receive buffer for easily access to the single values in the data packet. The problem is, that I cannot defind a variable, which only...
0
2076
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 border/background effects. Rather than duplicate the entire chunk of CSS 3 times, I thought "Gee, I should only have to specify the 3 backgrounds (all the other placement directives would be identical). However I must not be correctly specifying the...
3
27217
by: KNDesign | last post by:
I've set a background image to repeat-y and at 100% height. It appears fine when I open the window, but when I resize to a smaller height so that I must scroll down to see the rest, the background image is suddenly gone from the bottom. #background { position: absolute; top: 0px; bottom: 0px; left: 50%;
10
2603
by: Yevgen Muntyan | last post by:
Consider the following macro: #define ALLOCIT(Type) ((Type*) malloc (sizeof (Type))) The intent is to wrap raw memory allocation of N bytes into a macro which returns allocated chunk of memory to be used as a Type structure. The background: I was beaten many times (it surely is not my exclusive experience) by functions which return and accept void*. There are such functions,
4
2979
by: cherub | last post by:
I am not a programmer but i am trying to run the following script i thought i figured out with a book, but i am getting an error. Here is what i need it to do: From Outlook 03 Custom Contact Form with User defined fields to go to a word doc and print out. here is my alert message and not sure what to do or add to fix it: Object variable not set: 'strMyField' I worked on this all day yesterday and from this morning till now.. really...
6
7238
by: Rob | last post by:
Hello, I'm sure this has come up before. I have need for a collection of all elements/objects in an HTML document that have any kind of an attribute (HTML or CSS) that is making use of a URL to display an image. document.images only seems to reference image tags. The collection needs to include background images, input type = image, image maps, css assigned background, etc. Honestly, I am probably not aware of all the possibilities...
1
2450
by: nicky77 | last post by:
Hi, I've created a nav bar using a background image for rollover effects. Everything works as I had hoped, however, for some reason it seems that an area of whitespace (the same size of the background image) is hyperlinked underneath the nav bar. I can't see any errors in the coding below. Any ideas what may be causing this? the page is at http://www.maguiresonline.co.uk/wosis/files/nickysnav.html the html.... <body...
0
1212
by: Adam L. | last post by:
Howdy all. Quick background ? Pascal/Delphi programmer writing a software program in Pascal, coding the same program in parallel, in C. This is my long overdue goal to learn the C language. Been putting it off for about 6 years. :-) So far, so good. Just in the beginnings, but it's coming along. There is one thing that I have seen a few times that I can't seem to make sense of:
0
8946
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8776
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
9449
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
9182
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
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...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
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

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.