As
tftv256 remarks above,
HTML borrowed its color specification scheme from the
X11 window system. This is because the first browser to use these color codes,
Mosaic, was originally developed on this platform.
The 'HTML' color names are actually the color names defined in the X11 configuration file rgb.txt. The HTML hexcodes for colors are interpreted as
rgb values according to the X11 definition.
But the use of HTML colors is no longer limited to the X11 environment, and so they have assumed a life on their own, as part of HTML. For instance, in the original Mosaic, 'red' meant whetever the local X server found it to mean in rgb.txt. Now, 'red' means what the HTML standard defines it to mean. (well, theoretically speaking.)
The set of HTML colors is much smaller than the set of X colors.
Only 216 colors are actually web-safe: they are guaranteed
to exist on X, MS Windows, and Macintosh. (They are not guaranteed to have identical appearance.)