Bits & Bytes

Setting Colors in HTML with CSS

I have discussed how to specify a color with CSS in a prior post. Here, I will explain how the color specifications are used. To simplify the matter, I will use the hexadecimal color format for all of my color designations.

The basic block element has several distinct regions that can be specified, as I discussed in a another post on the CSS box model. Of these regions, three different colors may be selected for the border, background, and text, as shown below.

(Leviticus 10:9-11) You shall not drink wine nor any thing that may make drunk, thou nor thy sons, when you enter into the tabernacle of the testimony, lest you die: because it is an everlasting precept through your generations: And that you may have knowledge to discern between holy and unholy, between unclean and clean: And may teach the children of Israel all my ordinances which the Lord hath spoken to them by the hand of Moses.

The border is the outermost region that is colored bluish. When the border color is set, we need to specify the width and the pattern as well. In the example above, we set the border with this designation:
border:10px solid #88aacc;
To break this down, the border has a width of 10 pixels, a solid pattern, and is colored #88aacc.

Inside the border we have the background and the text. The background pinkish color is specified as
background-color:#ffddcc;
Against this background, we have a darker reddish, brown color for the text, which is specified as
color:#aa5522;
This is how the text color is set for any element.

The full specification for the div above, with all of the color and size styling, is given by this code below
<div style="width:420px; height:160px; padding:20px; border:10px solid #88aacc; background-color:#ffddcc; color:#aa5522; margin:20px;">
(Leviticus 10:9-11) You shall not drink wine nor any thing that may make drunk, thou nor thy sons, when you enter into the tabernacle of the testimony, lest you die: because it is an everlasting precept through your generations: And that you may have knowledge to discern between holy and unholy, between unclean and clean: And may teach the children of Israel all my ordinances which the Lord hath spoken to them by the hand of Moses.
</div>

Tags: , , , , , , , , , ,

Michael Hall

By: Michael Hall

Leave a Reply

*

 

© 2007–2024 XoaX.net LLC. All rights reserved.