DIV color

Can you set the color of a DIV? If so, how?Sure, just assign the desired background-color and color properties:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang='en'>
<head>
<title>Colored Div</title>
<META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=ISO-8859-1'>
<style type="text/css">
div.green {
background-color: green;
color: white;
padding: 1em;
margin: 1em auto;
width: 10em;
}
</style>
</head>
<body>
<div class=green>
<p>This is a test.</p>
<p>It is only a test.</p>
<div>
</body>
</html>You can also set the colour in hex numbers for better colour accuracy if you need to. Say if setting {background-color:green;} gives a slightly different shade of green than the adjacent element and you want them to match up nicely, you could say {background-color:#76C69A;} which would give a rather nice and softer tone of green. :D

Do you know how to write colours in that RGB hex triplet format or would you like some help? It's a lot more simple than it looks lol. ;)
 
Back
Top