I'm maintaining an old website and had the opportunity to touch old age HTML. So I encountered a strange behavior of the color
attribute.
In the following source code, both texts are red:
p {
color: #ff0000;
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>title</title>
</head>
<body>
<font color="#ff0000">
hello, world!
</font>
<p>
hello, world!
</p>
</body>
</html>
The color code consists of hexadecimal numbers and is (basically) 6 characters. However, the behavior of the color
attribute and the color
property differ when entering a color code of 6 characters or more.
p {
color: #ff0000abc;
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>title</title>
</head>
<body>
<font color="#ff0000abc">
hello, world!
</font>
<p>
hello, world!
</p>
</body>
</html>
Why is this and how the color
attribute works here? I still have to use the color
attribute, so I need to know this rule.
Based on this answer, I thought that the color code #ff00c0
was used, but according to inspect actually used color using firefox's dropper tool, actually #ff00ab
was using.
Following the answer you linked we will have the following steps:
#ff0000abc ---> # ff0 000 abc ---> # ff 00 ab ---> #ff00ab
And not #ff00c0
Without considering the #
You have 9 characters (divisible by 3) so you won't add any more. You group them into 3 and you cut the extra ones in each group to keep only 2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With