HTML White Code
This page contains HTML code for coloring an element white. You can use these HTML codes for setting the text color, background color, or the border color to white.
White Text
One way of setting the text color to white is by using inline styles. In the following example, I use the HTML <p>
tag along with the style
attribute.
You could also apply the styles against a <div>
tag (for all text within that element) or even the <body>
tag (for all text on the page).
Note that most browsers display a background color of white. Therefore, to display white text you will need to change the background color to a color that contrasts enough with the white text, that the text is readable. In this example, I set the background color to black, and the text color to white.
Source Code | Result |
---|---|
White text |
Here's the same thing, but this time using embedded styles.
Source Code | Result |
---|---|
White text |
You could also place the CSS code into a external style sheet.
White Border Color
You can create a white border around an element, however, the element will need to be contained within another element with a non-white background (otherwise you'll have white on white — unreadable to the human eye).
In this example, I've nested a <div>
element inside of another one. The outer <div>
has a background color of black
. The inner <div>
has a 3 pixel border with a color of white
and a background color of orange
.
Source Code | Result |
---|---|
I have a white border.
|
White Color Codes
The above examples use white
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 white in HTML.
Source Code | Result |
---|---|
White text White text (hexadecimal #ffffff) White text (hexadecimal shorthand #fff) White text (RGB value rgb(255,255,255)) |
Shades of White
Here are some different shades of whites and "whitish" colors that can be used instead of just plain old "white".