Re: Color in HTML

Dave Raggett (dsr@hplb.hpl.hp.com)
Wed, 8 Jun 94 10:54:22 BST


David Koblas writes:

> I know that HTML is not a formatting langauge, but it does present information
> and visual cues to attract peoples attention are very useful devices.
> It would be useful to be able to specify color in documents, for a variety
> of reasons. From fun/silly things like this:

> <P>John ate the <NEW_TAG COLOR=RED>red</NEW_TAG> apple.
> While Jill played in the <NEW_TAG COLOR=GREEN>green</NEW_TAG> grass.

The standard answer would be that color info belongs in the style sheet,
but I think it may be sufficiently important to provide direct support
within HTML itself. SGML processing instructions provide a way of including
presentation info, e.g.

<P>John ate the <?color red>red<?color> apple.
While Jill played in the <?color green>green<?color> grass.

Mosaic currently doesn't recognise processing elements as markup as so
they appear as typed. This is acceptable (IMHO) as it is obvious as to
what the author intended. We could define a limited set of named colors
in the DTD and use another processing instruction to declare new names, e.g.

<?ColorName "CadetBlue rgb 87 134 147">

A twist on this idea is to use SGML's processing entity definitions:

<!ENTITY green PI "color rgb 0 255 0"> (SGML Handbook page 41)
<!ENTITY red PI "color rgb 255 0 0">
<!ENTITY def PI "color default">

The example is then:

<P>John ate the &red;red&def;apple.
While Jill played in the &green;green&def; grass.

The DTD would then include a set of predefined colors, but authors could
extend this set via entity definitions in the DOCTYPE declaration.

<!DOCTYPE html [
<!ENTITY CadetBlue PI "color rgb 87 134 147">
<!ENTITY BlanchedAlmond PI "color rgb 254 232 198">
]>

Mosaic and other browsers show unknown entity references as typed.
The above DOCTYPE element appears as a solitary "]>". Neither of
these behaviours is that bad though. I guess my preference is for
the <?color> and <?colorname> method.

Isn't it worth considering a simple approach now as style sheets
will take a while to arrive?

These are only suggestions, so please don't flame me!

--
Best wishes,

Dave Raggett

----------------------------------------------------------------------------- Hewlett Packard Laboratories email: dsr@hplb.hpl.hp.com Filton Road tel: +44 272 228046 Stoke Gifford fax: +44 272 228003 Bristol BS12 6QZ United Kingdom