W3C home > Mailing lists > Public > www-validator@w3.org > November 2004

Re: Color in pages

From: Jukka K. Korpela <jkorpela@cs.tut.fi>
Date: Sun, 21 Nov 2004 19:06:07 +0200 (EET)
To: kingmacro@kingmacro.net
Cc: www-validator@w3.org
Message-ID: <Pine.GSO.4.58.0411211859460.5420@korppi.cs.tut.fi>

On Sun, 21 Nov 2004, KM wrote:

> "A color value may either be a hexadecimal number (prefixed by a hash mark)"

The jargon word word "hash mark" means the number sign "#", but you surely
had guessed that.

> however if you validate a page containing, for example:
>
> <font color="FF0000">Hello</font>
>
> the validator shows "This Page Is Valid HTML 4.01 Transitional!",

That's because it is valid. Validation is formal, and it only covers those
aspects of markup that are defined at the formal level (basically, in the
DTD); see http://www.cs.tut.fi/~jkorpela/html/validation.html for a longer
explanation.

In the DTD, the color attribute is declared as being of type CDATA. This
means that (almost) anything goes. But this only means that the DTD, and
hence validators, don't cover the rules for color attribute values.

> IE will ignore the lack of a # and render the page properly,

It is incorrect HTML, hence there is no "proper rendering"; error
processing is up to the browser.

> the HTTP specifications seem
> to say that its not valid HTML.

HTTP specifications do not define HTML at all.

> Unfortunately I didn't notice this until after I had gone through my
> entire site using IE making every page valid, and then tried opening
> it in Firefox.

Hint: Using CSS is superior to presentational HTML especially in
situations like this. What if you want to change #FF0000 to #F00000 later?
Using CSS, you would probably change one occurrence of the color specifier
only.

-- 
Jukka "Yucca" Korpela, http://www.cs.tut.fi/~jkorpela/
Received on Sunday, 21 November 2004 17:06:42 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 25 April 2012 12:14:15 GMT