HTML Colors
iDeskBD Forum :: E-EDUCATION :: HTML
Page 1 of 1
HTML Colors
In HTML, colors can be added by using the style attribute. You can specify a color name (eg, blue), a hexadecimal value (eg, #0000ff), or an RGB value (eg rgb(0,0,255)).
Syntax
Foreground Color
To add color to an HTML element, you use style="color:{color}", where {color} is the color value. For example:
HTML Colors
Background Color
To add a background color to an HTML element, you use style="background-color:{color}", where {color} is the color value. For example:
HTML Colors
Border Color
To add a colored border to an HTML element, you use style="border:{width} {color} {style}",
where {width} is the width of the border, {color} is the color of the
border, and {style} is the style of the border. For example:
HTML Colors
Color Names
The most common methods for specifying colors are by using the color
name or the hexadecimal value. Although color names are easier to
remember, the hexadecimal values and RGB values provides you with more
color options.
Hexadecimal values are a combination of letters and numbers. The
numbers go from 0 - 9 and the letters go from A to F. When using
hexadecimal color values in your HTML/CSS, you preceed the value with a
hash (#). Although hexadecimal values may look a little weird at first,
you'll soon get used to them.
There are 16 color names (as specified in the HTML 4.0
specification). The chart below shows these color names and their
corresponding hexadecimal value.
You can make up your own colors by simply entering any six digit
hexadecimal value (preceeded by a hash). In the following example,
we're using the same code as above. The only difference is that,
instead of using "blue" as the value, we're using its hexadecimal
equivalent (which is #0000ff):
HTML Colors
If we wanted to change to a deeper blue, we could change our hexadecimal value slightly, like this:
HTML Colors
Syntax
Foreground Color
To add color to an HTML element, you use style="color:{color}", where {color} is the color value. For example:
- Code:
<h3 [b]style="color:blue"[/b]>HTML Colors</h3>
HTML Colors
Background Color
To add a background color to an HTML element, you use style="background-color:{color}", where {color} is the color value. For example:
- Code:
<h3 [b]style="background-color:blue"[/b]>HTML Colors</h3>
HTML Colors
Border Color
To add a colored border to an HTML element, you use style="border:{width} {color} {style}",
where {width} is the width of the border, {color} is the color of the
border, and {style} is the style of the border. For example:
- Code:
<h3 [b]style="border:1px blue solid;"[/b]>HTML Colors</h3>
HTML Colors
Color Names
The most common methods for specifying colors are by using the color
name or the hexadecimal value. Although color names are easier to
remember, the hexadecimal values and RGB values provides you with more
color options.
Hexadecimal values are a combination of letters and numbers. The
numbers go from 0 - 9 and the letters go from A to F. When using
hexadecimal color values in your HTML/CSS, you preceed the value with a
hash (#). Although hexadecimal values may look a little weird at first,
you'll soon get used to them.
There are 16 color names (as specified in the HTML 4.0
specification). The chart below shows these color names and their
corresponding hexadecimal value.
Black | #000000 | Green | #008000 | |||
Silver | #c0c0c0 | Lime | #00ff00 | |||
Gray | #808080 | Olive | #808000 | |||
White | #ffffff | Yellow | #ffff00 | |||
Maroon | #800000 | Navy | #000080 | |||
Red | #ff0000 | Blue | #0000ff | |||
Purple | #800080 | Teal | #008080 | |||
Fushia | #ff00ff | Aqua | #00ffff |
You can make up your own colors by simply entering any six digit
hexadecimal value (preceeded by a hash). In the following example,
we're using the same code as above. The only difference is that,
instead of using "blue" as the value, we're using its hexadecimal
equivalent (which is #0000ff):
- Code:
<h3 [b]style="color:#0000ff"[/b]>HTML Colors</h3>
HTML Colors
If we wanted to change to a deeper blue, we could change our hexadecimal value slightly, like this:
- Code:
<h3 [b]style="color:#000069"[/b]>HTML Colors</h3>
HTML Colors
iDeskBD Forum :: E-EDUCATION :: HTML
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|