HTML Black Code
This page contains HTML code for coloring an element black. Typically, you might be changing the color of text or the background color of that text or another element. But you can also use HTML color codes to change the color of an element's border.
Black Text
One way of setting black text is by using the HTML
tag along with the style attribute. This is called inline styles.
However, depending on how much text you need to color, you could apply the styles against a
Source CodeResult
Black text
Black text
Here's the same thing, but this time using embedded styles.
Source CodeResult
.blackText {color:black;}
Black text
Black text
You could also place the CSS code into a external style sheet.
Black Background Color
You can set the background color of an element to black by using the CSS background-color property or the background shorthand property. If you do this, you will need to ensure that any text (or foreground element) is not black, in order for it to be visible.
In this example, I've placed the text inside a
Source CodeResult
White text, black background.
Black Border Color
When you use CSS to create a border around an element, you need to specify the border's color.
In this example, I've specified that the
Source CodeResult
Normal text, but with a border around the div element.
Black Color Codes
The above examples use black as the color value. I could just as easily used the hexadecimal or RGB color values and the result would've been the same.
Here are the various methods of specifying the color black in HTML.
Source CodeResult
Black text
Black text (hexadecimal #000000)
Black text (hexadecimal shorthand #000)
Black text (RGB value rgb(0,0,0))
Black text
Black text (hexadecimal #000000)
Black text (hexadecimal shorthand #000)
Black text (RGB value rgb(0,0,0))
Shades of Black
Here are some different shades of blacks & grays that can be used instead of just plain old "black".