Avatar of LuluDev
LuluDev
 asked on

Simple background-color - firebrick3 works for HTML, but not for CSS

I have two examples below to show the use of firebrick3 as a page background color. The HTML version works and shows firebrick3 page background; however the CSS version shows a white background. Why is there this apparent difference in the ability to use the key value firebrick3 in HTML, but not in CSS? Or is there an error in my code? I know how to get it to work in CSS ( use hex key value instead of firebrick3). But... I am curious why firebrick3 does not work and what I have to watch out for and why when using color names in CSS.

======= HTML version ===============
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>
Untitled
</title>
</head>
<body bgcolor="firebrick3">
Some body text here
</body>
</html>

======= CSS  version ================

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<style type="text/css">
<!--
/* I cannot get background:firebrick3 to work! But using hex will work #C11B17 */
body {background: firebrick3;}
-->
</style>
</head>
<body>
Some body text here
</body>
</html>
CSS

Avatar of undefined
Last Comment
TedInAK

8/22/2022 - Mon
TedInAK

While it is a recognized color for the deprecated "bgcolor" attribute, it isn't a recognized CSS color.
ASKER CERTIFIED SOLUTION
TedInAK

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
LuluDev

ASKER
Excellent link! I had rooted around a bit in w3c and had not found this document. So as the link you sent suggest... in CSS I will stick to using the 16 color names and if I reallly want firebrick3 I will use the hex equivalent!

Thank-you!
TedInAK

You're most welcome!
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck