Web Hosting Talk







View Full Version : Is bgcolor accepted by Netscape, Firefox, Opera?


boardr00
08-17-2004, 04:43 AM
When I load a page on these browsers non of my bg colors work. They only work in IE.

Here is an example tag:

<td bgcolor="f7f7f7">

It is meant to color the cell gray but it doesn't work in the above listed browsers. Any explinations?

Zopester
08-17-2004, 04:48 AM
Because the correct implementation is :

<td bgcolor="#f7f7f7">

boardr00
08-17-2004, 04:50 AM
Thank you for the help Zopester.

Zopester
08-17-2004, 04:55 AM
I could mention that you really should be doing this styling using CSS, but that's a discussion for another day. :)

boardr00
08-17-2004, 05:04 AM
I suppose I should. I just don't have the time to change everything right now. If I used css would it improve load times etc? or just make it correct. I know I should do it either way, and I will when I can make time.

Zopester
08-17-2004, 05:14 AM
It would definitely improve load times. There are ways of minimizing the HTML and retaining the same look. For example, you could add a class to a table (eg <table class="myclass">), and for all table cells you could specify a background-color of #f7f7f7:


table.myclass td {
background-color:#f7f7f7;
color:#000;
}


That means you can remove every iteration of bgcolor="#f7f7f7" from your HTML, reducing load times. That's one simple example, there are plenty more.

Rich2k
08-17-2004, 05:21 AM
The bgcolor attribute is deprecated from later versions of HTML and XHTML so you shouldn't use it if you can avoid it.

Gen-T
08-17-2004, 06:46 AM
Originally posted by Rich2k
The bgcolor attribute is deprecated from later versions of HTML
Ok, so it's best to use CSS instead. I understand.

However, when I read stuff like that, my heart skips a beat and my head gets dizzy, because I don't really understand what it means exactly, or the impact it will/can have. So can Rich (or anybody) explain: what will happen to a page designed using the bgcolor attribute, and when will it happen? Realistically what should my (and everyone's) fear be about continuing to use it?

Zopester
08-17-2004, 06:52 AM
what will happen to a page designed using the bgcolor attribute

It will continue to work. bgcolor is a recognised attribute in HTML 3.2 (a standard, if not a current one). No browser manufacturer is going to drop support for a standard just because it's getting on a bit. ;)

Zopester
08-17-2004, 06:54 AM
And from the W3C themselves on deprecated attributes (http://www.w3.org/TR/html4/conform.html#deprecated):


A deprecated element or attribute is one that has been outdated by newer constructs. Deprecated elements are defined in the reference manual in appropriate locations, but are clearly marked as deprecated. Deprecated elements may become obsolete in future versions of HTML.

User agents should continue to support deprecated elements for reasons of backward compatibility.

Gen-T
08-17-2004, 07:08 AM
Ok, I'm probably being obsessive here, but it seems like a contradiction.

---------
Deprecated elements may become obsolete in future versions of HTML.

User agents should continue to support deprecated elements for reasons of backward compatibility.
---------

How can it be obsolete, if it will continue to be supported?

We are not talking about the latest graphics card or processor. We are talking about code. Lines of text and characters. So I just don't understand what exactly the point of calling it deprecated or obsolete is. If it still works today as good as it worked 3 years ago, what is the point?

Am I making any sense at all? :eek2:

Rich2k
08-17-2004, 07:50 AM
What it means is that if you start designing your sites to newer versions of HTML you may find that deprecated elements may not work.

For instance bgcolor in <td> Works in HTML 4.0 and XHTML 1.0 Transitional as bgcolor is marked as deprecated in those elements.

If you set your DOCTYPE to XHTML 1.1 or XHTML 1.0 Strict you'll find that bgcolor doesn't exist in the document type definition so you can't rely on a user agent displaying it in that situation.

the_pm
08-17-2004, 08:43 AM
what will happen to a page designed using the bgcolor attribute, and when will it happen? Realistically what should my (and everyone's) fear be about continuing to use it?
That is the million dollar question! (more in a moment)

Deprecated means the element is not part of the current W3C HTML specification. As of 1999, when the last spec was released, the W3C recommended backward compatibility, though it warned developers that browser support could not be guaranteed. That was five years ago!

The W3C has not released a new HTML specification since then because it is instead developing XHTML to be the universal Web standard. Now, before everyone gets all bent out of shape, XHTML is simply HTML with a bunch of garbage pulled out. There's nothing special about it except that it strives (for the most part successfully) to completely separate style elements (which are handled in CSS) from structural elements (which remain in HTML/XHTML).

So, in truth, HTML 4.01 is becoming an "old" standard because it is no longer being refined, and we'll never see deprecated tags and attributes become obsolete because, if things go as planned, the entire HTML specification will become deprecated, and then obsolete!

But if you've been writing strict HTML 4.01 all along, you have nothing to fear. This is pretty much where XHTML picked up. You can write strict HTML and declare a strict or transitional DOCTYPE - it rarely affects anything (I write strict HTML 4.01 and declare transitional all the time). However, if you're using HTML 3.2 or even 4.0 elements, it's possible you'll be in for a nasty surprise down the road.

How far down the road? Well, there's no way of knowing that for certain. That's up to each individual browser company/development team. But you do know two things:
1. If you use deprecated/obsolete markup that hasn't been recognized as being part of the current industry standard, you will live in a state of perpetual uncertainty until one day...one day...it all stops working and you're screwed. Might be next year - might be in five years, but that's your uncertainty with which you must grapple.
2. If you use standard markup, you're worry-free :)

So, while Zopester may be right about HTML 3.2 still being supported, I'm more comfortable knowing my HTML 4.01 is going to be supported (and I know you agree, M ;) )

Remember, the recommendation to continue support for deprecated markup is five years old!

The other side of the argument against using HTML attributes to style your page has to do with usability, user style sheets, and the like. And I'll sum that part up in a couple of sentences. Proper separation of style into CSS almost alway guarantees user needs will be honored. When visitors can't use your site, *click* *click* - they just change the channel ;)

Gen-T
08-17-2004, 09:07 AM
Some good stuff in this thread, and worth bookmarking.

By the way.....

I - H a t e - C o d e

LOL :rofl:

boardr00
08-17-2004, 03:11 PM
Another question regarding backgrounds. Right now I am using a 1px transparent image to hold empty cells to the right size. Is there a better way to do this? possibly css?

the_pm
08-17-2004, 03:14 PM
Yep. Ditch the empty cells completely. Their only function is to pad stuff, which is what CSS does (read up on 'margin' and 'padding'). Of course, you're getting deeper into a reengineering project, but better to get it done right than to be content with having a site built with a shaky foundation.

I still owe you some optimization techniques. I will get there - I'm still collecting myself after my exhausting trip!

boardr00
08-17-2004, 03:18 PM
Thanks for the help the_pm. Yes, I have just built my site so it is not really being used by clients yet. My goal is to get this all done right first. I must admit that I am not a web designer, so any help is greatly appreciated.