HTML Colors:

Video link: https://youtu.be/X1Rf-ipDtwI

HTML colors are specified with predefined color names, or with RGB, HEX, HSL, RGBA, or HSLA values.

Color Names

In HTML, a color can be specified by using a color name:

Tomato

Orange

DodgerBlue

MediumSeaGreen

Gray

SlateBlue

Violet

LightGray

HTML supports 140 standard color names.


Example 1:

<body>

<h1 style="background-color: tomato;">Tomato</h1>

<h1 style="background-color:Red;">Red</h1>

<h1 style="background-color:dodgerblue;">Dodgerblue</h1>

<h1 style="background-color:Orange;">Orange</h1>

<h1 style="background-color:Yellow;">Yellow</h1>

<h1 style="background-color:mediumseagreen;">Mediumseagreen</h1>

<h1 style="background-color:Gray;">Gray</h1>

<h1 style="background-color:slateblue;">Slateblue</h1>

<h1 style="background-color:violet;">Violet</h1>

<h1 style="background-color:Lightgray;">Lightgray</h1>

</body>


Background Color:

You can set the background color for HTML elements:

Example 2:

<body>

<h1 style="background-color: tomato;">Tomato</h1>

<h1 style="background-color:Red;">Red</h1>

<p style="background-color: turquoise;">Hello World</p>

<p style="background-color: violet;">Hello World</p>

</body>


Text Color:

You can set the color of text:

Example 3:

<body>

<h1 style="color:blue">Hello World</h1>

<p style="color:Red">Hello World</p>

<p style="color:Orange">Hello World</p>

</body>


Border Color

You can set the color of borders:

Example 4:

<body>

<h1 style="border:2px solid black;">Hello World</h1>

<p style="border:2px solid orangered">Hello World</p>

<p style="border:2px solid red">Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsum officiis unde blanditiis deleniti ut at ab nulla laborum minus rem, dicta modi in beatae omnis neque fuga illum vel dolorum.</p>

</body>