Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Mar 2006
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    validation of html and css

    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.

    Code:
    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 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
    reza ryan naghibi

  • #2
    Regular Coder
    Join Date
    Mar 2006
    Location
    Connecticut, USA
    Posts
    400
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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.
    Last edited by bustamelon; 04-24-2006 at 09:41 PM.

  • #3
    New Coder
    Join Date
    Mar 2006
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by bustamelon
    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?
    reza ryan naghibi

  • #4
    Regular Coder
    Join Date
    Mar 2006
    Location
    Connecticut, USA
    Posts
    400
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by rezachemical
    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;

  • #5
    Regular Coder DELOCH's Avatar
    Join Date
    Apr 2006
    Location
    Canada
    Posts
    537
    Thanks
    4
    Thanked 2 Times in 2 Posts
    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

  • #6
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,372
    Thanks
    32
    Thanked 286 Times in 280 Posts
    @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;}
    Last edited by Arbitrator; 04-25-2006 at 08:41 AM.
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • #7
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Quote Originally Posted by Arbitrator
    [@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]

  • #8
    Regular Coder oldcrazylegs's Avatar
    Join Date
    Feb 2004
    Location
    East Moline Illinois USA
    Posts
    414
    Thanks
    4
    Thanked 5 Times in 4 Posts
    i use background-color:inherit; works fine


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •