Forum Moderators: open
I have a table with populated cells. It has a bgcolor.
The color is recognized in IE and NS Navigator (4.5!) but NOT in NS7.02. What gives? I am driving myself crazy.
The workaround is to use a background image for the page, or to set a background color for the page. I just can't stand not knowing why this doesn't work the way it *should* by setting bgcolor for the table - searched the archives & found no reference. HEre's the code:
<body>
<table width="796" border="0" cellspacing="0" cellpadding="0" bgcolor="6666FF">
Thanks in advance...
bgcolor is a deprecated attribute [webmasterworld.com] - use CSS and you should have better results cross-browser. No way to tell how long any browser support will be given for deprecated attributes, so it's better to future-proof your mark-up.
style="background-color:#6666FF;"
Also consider handling all the other attributes of your table with css - ideally in a seperate .css file. That way you can control border, padding, etc for each individual cell as well as the whole table and create very pleasing visual effects.
<table width="796" border="0" cellspacing="0" cellpadding="0" bgcolor="6666FF">
You're probably using a full doctype which switches Netscape 7 into standards-compliance mode. The above use of bgcolor is missing the "#" before the color value. In quirks mode (which emulates the bugs of older browsers such as Netscape 4.7) this is permitted, but in standards-compliance mode it won't work.
You should try using
[b]bgcolor="#6666FF"[/b] instead. Should fix your problem. See also Quirks Mode and Standards Mode [webmasterworld.com] for more information.
You should also run your page through a validator, which will help you pick up on such problems more easily in the future:
[validator.w3.org...]