Link to home
Start Free TrialLog in
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>
Avatar of TedInAK
TedInAK
Flag of United States of America image

While it is a recognized color for the deprecated "bgcolor" attribute, it isn't a recognized CSS color.
ASKER CERTIFIED SOLUTION
Avatar of TedInAK
TedInAK
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of LuluDev
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!
You're most welcome!