8

I am new to HTML 5 and I have problems to find out in the diverse W3 HTML standardization documents to obtain the status of an attribute.

For example, the bgcolor attribute of the <body> element should not be used any longer since HTML 4.01. It was deprecated. (see: http://www.w3.org/TR/html4/present/graphics.html#h-15.1.1).

However what is it's status in HTML 5? In the HTML markup specification that attribute is marked as obsolete (see: http://www.w3.org/TR/html-markup/body.html).

Does this mean by the book, the attribute does not exist any longer in HTML 5?

Considering writing a standard conform client, to which reference in the docs should I relate to to have precise and defined dealing for the attribute? Just drop it because it is obsolete? Leave it in there but otherwise being deaf about it (there is an attribute node but it has no meaning)?

Where is that documented in the standardization documents?

Gordon
  • 312,688
  • 75
  • 539
  • 559
hakre
  • 193,403
  • 52
  • 435
  • 836
  • Is your questions about the "official" standpoint of the W3? How user agents should treat obsolete features? – Mr Lister Nov 18 '12 at 11:57
  • 1
    @Dale can specify the section you pointing since this link makes no sense – NullPoiиteя Nov 18 '12 at 11:58
  • @Mr Lister: As I understood it right, HTML 5 *defines* how to treat the diverse statuses. So sure, the documented standpoint, otherwise it would not be constructive to ask for this. I mean I can not pull out Netscape 2.01 Gold and say it's done that way with it. Well I could, but that is not what I ask for ;) – hakre Nov 18 '12 at 12:00
  • Yes. Well, HTML 4 allowed user agents to keep the value of unknown attributes (so they could be queried by Javascript for instance), but HTML5 doesn't, so if you need to put a value in an element, use a _data-*_ attribute, because that's what those are for. And I wish I could find the official reference, so I could give you a link. – Mr Lister Nov 18 '12 at 12:06
  • @hakre - Actually, the 3.2 *DTD* doesn't say what to do with bgcolor, it just indicates it's valid. The 3.2 *spec* says that it is the background colour for the document body, but doesn't define what that means. The precise rendering details are left to the later CSS spec to define. – Alohci Nov 18 '12 at 12:34
  • Just wanted to mention I have a bookmarklet that gets rid of obsolete attributes on the fly and spits out the 'generated' source html so you can see what attributes you need to get rid of in existing markup. feel free to use it > http://keithwyland.github.com/attrebuke/ – keithwyland Jan 23 '13 at 18:36

1 Answers1

3

If you are asking about what a user agent should do, for the case of bgcolor on the <body> element, that's defined for HTML5 in the Rendering Section, where it says:

When a body element has a bgcolor attribute set, the new value is expected to be parsed using the rules for parsing a legacy color value, and if that does not return an error, the user agent is expected to treat the attribute as a presentational hint setting the element's 'background-color' property to the resulting color.

Alohci
  • 78,296
  • 16
  • 112
  • 156
  • So this is specified for each concrete attribute name of a concrete element name? Or is there a general rule? And what is the meaning of obsolete then? Where is define what it means when an attribute is obsolete? – hakre Nov 18 '12 at 12:37
  • 'Obsolete' means that web authors should not use them. Whether an element or attribute is obsolete is not relevant to user-agents' implementations. – Alohci Nov 18 '12 at 12:40
  • Well, it looks like that the whole `bgcolor` attribute has been re-defined in HTML5. So the move is to first obsolete it to ignore earlier HTML versions rules (because it was deprecated earlier and is obsolete now, it does not exist any longer) and then introduce a new meaning and rules for processing. It might be more straight forward to mark it as obsolete and redefined then. – hakre Nov 18 '12 at 12:43
  • I don't think so. In browsers, bgcolor in HTML5 does what is has always done. It is obsolete because authors should use CSS instead. But browsers are required to support old web pages too, so they need to treat bgcolor backwards compatibly. – Alohci Nov 18 '12 at 12:46
  • Well the parsing rules for HTML 5 (as you have outlined them) are *not* backwards compatible to HTML 4.01. So I wonder how that goes together well. Additionally it introduces a further burden for authors and implementors (which on it's own must not be discussed, first step would be to actually have reference that the values and parsing of those changed). – hakre Nov 18 '12 at 12:48
  • Right. HTML5's notion of `backward compatibility` is that the spec should be backwards compatible with the legacy processing of real world web pages, and not necessarily with being backward compatible with previous HTML specifications. – Alohci Nov 18 '12 at 12:54
  • So backwards compatibility in HTML 5 does not cover the standard implementations of previous HTML versions? Just asking to get this right, that is backwards compatibility to an unknown past? I wonder how that should work, otherwise, it makes sense to have this esoteric if you see who pays editors right now. :) – hakre Nov 18 '12 at 12:56
  • The idea is that the HTML5 spec is documenting that unknown past. As far as I can see, everything you need for implementing bgcolor in a browser is in either the HTML5 spec or the CSS spec. – Alohci Nov 18 '12 at 13:03
  • I do not like to speculate about ideas here, that one for example I do not see represented by the book. Also what I don't understand in the specs is the discrepancy between "there is no bgcolor attribute with the body tag" and "When a body element has a bgcolor attribute set". So is there now a bgcolor attribute by the book or not? – hakre Nov 18 '12 at 13:15
  • There is for browser implementations - when and where it makes sense for them. It's a presentational hint, because, for example bgcolor makes no sense on a Braille browser. – Alohci Nov 18 '12 at 13:25
  • Hmm, as much as `background-color`. Presentation. – hakre Nov 18 '12 at 13:49
  • You should differentiate between HTML5 compliant browsers and non-HTML5 compliant browsers. If your browser "does" HTML5, it should treat obsolete attributes in HTML5 documents as non-existent; i.e. ignore them as junk. If the browser doesn't recognise HTML5, then it should threat the document as HTML4 (or whatever version it does know about) and handle those attributes accordingly. That's all there is to it. – Mr Lister Nov 18 '12 at 14:06
  • As written, I've problems to actually find that in the books. – hakre Nov 18 '12 at 14:48
  • 3
    @hakre - That's because it's not there, because it's not true. – Alohci Nov 18 '12 at 16:02