CSS Border Color
You can set the color of borders:
<h1 style="border:2px solid Tomato;">Hello World</h1>
<h1 style="border:2px solid DodgerBlue;">Hello World</h1>
<h1 style="border:2px solid Violet;">Hello World</h1>
In CSS, colors can also be specified using RGB values, HEX values, HSL values, RGBA values, and HSLA values:
Same as color name "Tomato":
rgb(255, 99, 71)
#ff6347
hsl(9, 100%, 64%)
Same as color name "Tomato", but 50% transparent:
rgba(255, 99, 71, 0.5)
hsla(9, 100%, 64%, 0.5)
<h1 style="background-color:rgb(255, 99, 71);">...</h1>
<h1 style="background-color:#ff6347;">...</h1>
<h1 style="background-color:hsl(9, 100%, 64%);">...</h1>
<h1 style="background-color:rgba(255, 99, 71, 0.5);">...</h1>
<h1 style="background-color:hsla(9, 100%, 64%, 0.5);">...</h1>
Same as color name "Tomato":
Same as color name "Tomato", but 50% transparent:
In addition to the predefined color names, colors can be specified using RGB, HEX, HSL, or even transparent colors using RGBA or HSLA color values.
CSS background-color
The background-color property specifies the background color of an element.
Example in html
This page has a light blue background color!
With CSS, a color is most often specified by:
Look at CSS Color Values for a complete list of possible color values.
You can set the background color for any HTML elements:
Here, the and elements will have different background colors:
Example in html
This is a text inside a div element.
This paragraph has its own background color.
We are still in the div element.
CSS background-image
The background-image property specifies an image to use as the background of an element.
By default, the image is repeated so it covers the entire element.
Example in html
This page has an image as the background!
If the image above is repeated only horizontally (background-repeat: repeat-x;), the background will look better:
Example
Here, a background image is repeated only horizontally!
CSS background-repeat: no-repeat
Showing the background image only once is also specified by the background-repeat property:
Example
W3Schools background image example.
The background image is only showing once, but it is disturbing the reader!