...

View Full Version : validation of html and css



rezachemical
04-24-2006, 08:37 PM
okay so i validated the css and html in my file over at http://gregharrison.freerealestatesoftware.net and it gave me back 3 errors that don't exactly mean anything to me.


Line : 68 (Level : 1) You have no background-color with your color : #menu_div

#menu_div {
float:left;
font-size:70%;
color:#000;
width:20%;
border:1px solid red;
}


this is just one of them. i was quite certain that declaring "color:value" would set the color of my text. i don't see how the background-color has to do w/ it.

i bring this up because last week i had posted (http://www.codingforums.com/showthread.php?t=84841) about not being able to get a proper look despite my stylesheet. it is coming to be a problem now that my html is valid. the same problems exist.

my only solution is to restart the style from scratch, but i'm hoping for a more constructive solution. please help

bustamelon
04-24-2006, 08:42 PM
It means just what it says: you have no background-color with your foreground color. This is not necessarily a problem if the inherited background color contrasts with the foreground color, but W3C wants both specified, so you don't run the risk of having the same color in your background and foreground, in which case you would not be able to see the foreground text. Dig? In addition, there is a potential SEO problem there too, because "cheaters" have often spammed their pages with keywords using the background color. This used to fool the search engines, while being invisible to the user. Now the SE's penalize and even ban sites for doing this, whether it's intentional or not. Just specify the bg color and it will stop complaining.

rezachemical
04-25-2006, 01:18 AM
It means just what it says: you have no background-color with your foreground color. This is not necessarily a problem if the inherited background color contrasts with the foreground color, but W3C wants both specified, so you don't run the risk of having the same color in your background and foreground, in which case you would not be able to see the foreground text. Dig? In addition, there is a potential SEO problem there too, because "cheaters" have often spammed their pages with keywords using the background color. This used to fool the search engines, while being invisible to the user. Now the SE's penalize and even ban sites for doing this, whether it's intentional or not. Just specify the bg color and it will stop complaining.

what if i wna leave it as no bg color? should i just do background-color:none?

bustamelon
04-25-2006, 02:26 AM
what if i wna leave it as no bg color? should i just do background-color:none?

You can do
background-color: transparent;
or
background-color: inherit;

DELOCH
04-25-2006, 03:59 AM
transparent won't work i tried

use the color that fits the bg the most, most of the time:

#FFFFFF aka White

so add


background-color: #FFFFFF;

also i noticed you do not indent , get into habit of

instead of doing

body {
background-color:White;
}

do this

body {
background-color: White;
}

take 1 indent after :

and any nomber on the beginning, i got used to making 4 spaces


k hope it helps

Arbitrator
04-25-2006, 08:38 AM
@rezachemical: That error you're receiving is just a warning if you read the header above it. The validator just warns you of possible conflicts in your code and are just something for you to keep in mind; it doesn't mean that your code is invalid.

In this case is warns if you have set either the background or font colors but not both since there can be a possible readability conflict for people that have set their default browsing colors different than the usual black text, white background, blue links, and purple visited links; all of the main browsers allow you to do this so it remains a possibility. You might also see other warnings like if you set a font to Verdana but don't specify a font-type in case the user doesn't have that font. For example, with Verdana you would probably specify sans-serif as your font type since that's the type of Verdana and the user's OS would pick a sans-serif font if it didn't have that font available; people that might not have this font are Mac users.

Not something you have to do. Just a warning.

@DELOCH: transparent should work and is a valid value to the CSS background-color property. You shouldn't notice any effect though since the default value is transparent (see-through). The white spaces are also irrelevant except when separating multiple property values. It's just a matter of preference toward organization and aesthetics. I personally subscribe to the use of indentation and property-value spacing but it's not necessary; this code is perfectly valid:

#menu_div{float:left;font-size:70%;color:#000;width:20%;border:1px solid red;}

Bill Posters
04-25-2006, 10:20 AM
[@DELOCH: transparent should work and is a valid value to the CSS background-color property. You shouldn't notice any effect though since the default value is transparent (see-through).
...which is precisely why the validator won't accept it as a value to remove the warning. A transparent background is no more of an assurance against unreadable contrast between colour and background than not declaring a background-color at all.
...as bustamelon already explained.[/QUOTE]

oldcrazylegs
04-25-2006, 11:18 PM
i use background-color:inherit; works fine



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum