Re: Color in pages

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 UTC