CSS: Backgrounds - How to Set the Background Color
(Page 2 of 5 )
You can set the background color of an object using the background-color property. Here is some code to show you how to do so for several elements, using colornames, colorcodes, and hexvalues:
<html>
<head>
<style type="text/css">
body {background-color: white}
h1 {background-color: #FF8C00}
h2 {background-color: yellow}
h3 {background-color: green}
h4 {background-color: blue}
h5 {background-color: indigo}
h6 {background-color: violet}
p {background-color: rgb(208,0,0)}
pre {background-color: transparent}
</style>
</head>
<body>
<p>Look a rainbow!</p>
<h1>Death to Rainbow Bright</h1>
<h2>Death to Rainbow Bright</h2>
<h3>Death to Rainbow Bright</h3>
<h4>Death to Rainbow Bright</h4>
<h5>Death to Rainbow Bright</h5>
<h6>Death to Rainbow Bright</h6>
<pre> Look! Transparency!</pre>
</body>
</html>
This would result in:

Next: Working with Background Images >>
More Style Sheets Articles
More By James Payne