2

While reading a chapter of Interneting Is Hard, I clicked on a link to this page on MDN about colors in CSS. It contains this interesting paragraph in a part about problems with color keywords:

HTML only recognizes the 16 basic color keywords found in CSS1, using a specific algorithm to convert unrecognized values (often to completely different colors).

What exactly does this mean? What sort of algorithm does HTML use to attempt to find out what color text is trying to represent? What are the limitations that cause it to mess up? If this is pretty different between browsers, what do Firefox and Chrome do in this scenario?

Stormblessed
  • 201
  • 4
  • 16
  • in short: nothing. Html is pretty forgiving in general - It will try (also forgiving) to parse your value. If it can't parse the color not even in the slightest, it will fallback to default.. – riffnl Jan 17 '20 at 22:17
  • I'm guessing the algorithm is specific to the rendering engine. – Marc Jan 17 '20 at 22:20
  • @Marc I have edited the question to specify Firefox and Chrome if it varies much. – Stormblessed Jan 17 '20 at 22:22
  • It is worth pointing out that the "NOTE" box below that comment extends the definition to include new versions of CSS. As per your question, this doesn't change how HTML handles color names that it doesn't recognize, but it does introduce support for way more that 16 colors. – jwatts1980 Jan 17 '20 at 22:25
  • 2
    You may be interested in [@dash’s answer](https://stackoverflow.com/a/8333464/82548) to this question: “[Why does HTML think “chucknorris” is a color?](https://stackoverflow.com/q/8318911/82548)” – David Thomas Jan 17 '20 at 22:25

1 Answers1

0

As the comments say it would most likely default to your element's default or inherited color.

In the browser's inspector the rule would appear as invalid CSS.

Mihail Minkov
  • 2,463
  • 2
  • 24
  • 41