there is no attribute "bgcolor".

Discussion in 'CSS' started by mrcountry, Mar 17, 2008.

  1. #1
    <td bgcolor="#FFFFFF" style="height:38"><div style="text-align:center ">

    Someone please help me out with this error. I would greatly appreciate it.
     
    mrcountry, Mar 17, 2008 IP
  2. LordXenu

    LordXenu Active Member

    Messages:
    313
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #2
    <td style="height:38; background: #ffffff;"><div style="text-align:center">
     
    LordXenu, Mar 17, 2008 IP
  3. chapicha

    chapicha Peon

    Messages:
    235
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    <td height="38" bgcolor="#99CCCC">abc</td>
     
    chapicha, Mar 17, 2008 IP
  4. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #4
    So you ran this through the validator? Just so you know, it's invalid (deprecated) but it does still work. If you just want to validate the page because you feel better, you'll likely need a CSS sheet and move ALL these values into it. It'll certainly make your HTML smaller and easier to read.

    Depending on whether this background colour is all td's or just some, you could set a style like this (if it's all td's):
    td {
    background-color: #fff;
    height: 38px;
    }
    td div {
    text-align: center;
    }

    The above is valid, but like I said, it depends on how your page is set up whether you want it like that. If it's only that td that is white, you might want to throw a class on it or something, or if it's only td's in a particular table, give that table a class or id and refer to the td's through that:

    <table id="awesometable">

    CSS
    #awesometable td {
    background-color: #fff;
    height: 38px;
    }

    Or whatever.
     
    Stomme poes, Mar 18, 2008 IP
  5. mrcountry

    mrcountry Active Member

    Messages:
    45
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #5
    Thanks so much for the help. I really appreciate it. You folks are the best.
     
    mrcountry, Mar 18, 2008 IP
  6. winterheat

    winterheat Peon

    Messages:
    125
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    i usually like to use background: orange instead of background-color: orange

    the same goes for border: none versus border-style:none
     
    winterheat, Mar 20, 2008 IP
  7. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I am leary of using the shortcuts for one property. Apparently "background" is cool with whatever you give it, but other shorthands ("font" comes to mind) require a certain minimum number of properties to work.
     
    Stomme poes, Mar 21, 2008 IP
  8. winterheat

    winterheat Peon

    Messages:
    125
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    yeah i wonder... why

    font: 20px;
    HTML:
    or

    font: Arial;
    HTML:
    will choke when human can perfectly understand it.
     
    winterheat, Mar 21, 2008 IP
  9. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Eh, humans wrote it. But browsers aren't humans. Have you ever seen the code it takes just to get a robot to recognise something from an image? Babies can do that automagically. Machines aren't bright, so while someone somewhere said to the machines specifically, "background is for this, that, the other, or any one of them alone" and didn't for font. And who knows, the people who write the specs are not the people who write the browsers, so there could well be browsers who will make a good guess that font: arial means font-family: arial.

    Take this, I just saw it the other day on SitePoint:
    background: #fff url(whatever.gif)left top no-repeat;

    Everyone was cool except IE, who did not show the background (or any background stuck in there...). Why were the other browsers showing the image?

    IE was tripped up by a simple typo. There's no space between the closing ) and the word "left". The other browsers knew that )left should have been ) left. IE didn't.

    This is actually a Bad Thing. When you send XML to an XML parser, it stops at the first error and sits there and tells you, "There's an error. Fix it." It will not display the document. It shouldn't, either-- you should fix the error.
    Browsers are supposed to do that, but of course that means more work for webmasters and no single browser maker wants to be the only one who makes a browser that doesn't display pages based on some little error when all the other browsers just show the page (and guess their way around the error).

    So, I just try to not take my chances. If I've been explicitly told that I can use "background" as a shortcut for two or more properties, then that's what I go with, even if everyone is cool with a shortcut using only one property. I feel that doing so strengthens or stabilises my code, knowing that any new browsers are in fact MORE likely to follow the spec than earlier (and where the spec is ambigious, this is also a good thing... like, the spec doesn't say if - is okay in a class name. Most browsers have no problem with it, but Opera does in certain instances, which gives us a way to hack for Opera til they fix it : )

    Another example is background-position: bottom 50%; technically, it's now okay with modern browsers to mix names and metrics, but we don't because it's more stable (and backwards friendly) to keep names with names and metrics with metrics... and while the first value should be the horizontal, most browsers should be able to figure out that they've been mixed... but why count on that chance when you can totally cover your butt with background-position: 50% 100%; the second value being "bottom"...?

    So it's not really a question of, "but this should work, so it's okay," but "what covers my butt just in case...".
     
    Stomme poes, Mar 22, 2008 IP