Skip to main content

CSS Border Color

The border-color property sets the color of the four borders.

The color can be given as a name (like red), a HEX value (like #ff0000), an RGB value (like rgb(255,0,0)), an HSL value (like hsl(0, 100%, 50%)), or transparent.

Note: If border-color is not set, the border uses the element's text color.

Example

Each paragraph has a border in a different named color.

Prompt
An HTML page that demonstrates different border colors using color names. In an internal <style> block, make three bordered paragraph classes: solid red, solid green, and dotted blue. Each must set border-style too. Add a paragraph for each.
Output: complete HTML page

Specific Side Colors

The border-color property can take from one to four values, for the top, right, bottom, and left borders.

Example

Four values give each side its own color.

Prompt
An HTML page that gives each border side a different color. In an internal <style> block, make a solid-bordered paragraph with border-color "red green blue yellow" (red top, green right, blue bottom, yellow left). Add a paragraph using it.
Output: complete HTML page

HEX Values

The border color can also be set with a hexadecimal (HEX) value.

Example

The border color is set with the HEX value #ff0000.

Prompt
An HTML page that sets a border color with a HEX value. In an internal <style> block, make a solid-bordered paragraph with border-color #ff0000 (red). Add a paragraph using it.
Output: complete HTML page

RGB Values

The border color can also be set with an RGB value.

Example

The border color is set with rgb(255, 0, 0).

Prompt
An HTML page that sets a border color with an RGB value. In an internal <style> block, make a solid-bordered paragraph with border-color rgb(255, 0, 0) (red). Add a paragraph using it.
Output: complete HTML page

HSL Values

You can also set the border color with an HSL value.

You can learn more about HEX, RGB, and HSL in the CSS Colors chapters.

Example

The border color is set with hsl(0, 100%, 50%).

Prompt
An HTML page that sets a border color with an HSL value. In an internal <style> block, make a solid-bordered paragraph with border-color hsl(0, 100%, 50%) (red). Add a paragraph using it.
Output: complete HTML page