Loading

Colors

  • Colors are used to give colours to text, background and borders.
  • There are many types of colours used in HTML like tomato, grey, orange, black etc.

Text Color

  • It is used to give colour to the texts.

Syntax:

    <h2 style="color:blueviolet">text color example1</h2>
    <h3 style="color:yellow">text color example3</h3>
    <p style="color:blue">text color example2</p>

Example:

<!DOCTYPE html>
<html>

<head>
    <title>color</title>
</head>

<body>
    <h2 style="color:blueviolet">text color example1</h2>
    <h3 style="color:yellow">text color example3</h3>
    <p style="color:blue">text color example2</p>
</body>

</html>

Output:


Background Color

  • It is used to give colour to the backgrounds.

Syntax:

<body style="background-color: antiquewhite;">
    <h2 style="background-color:blueviolet">background color example1</h2>
    <h3 style="background-color:yellow">background color example3</h3>
    <p style="background-color:blue">background color example2</p>
</body>

Example:

<!DOCTYPE html>
<html>

<head>
    <title>color</title>
</head>

<body style="background-color: antiquewhite;">
    <h2 style="background-color:blueviolet">background color example1</h2>
    <h3 style="background-color:yellow">background color example3</h3>
    <p style="background-color:blue">background color example2</p>
</body>

</html>

Output:


Border Color

  • It is used to give colour to the borders of tables, boxes, texts etc

Syntax:

    <h2 style="border:2px solid orange">border color example1</h2>
    <h3 style="border:2px solid yellow">border color example3</h3>
    <p style="border:2px solid blue">border color example2</p>

Example:

<!DOCTYPE html>
<html>

<head>
    <title>color</title>
</head>

<body>
    <h2 style="border:2px solid orange">border color example1</h2>
    <h3 style="border:2px solid yellow">border color example3</h3>
    <p style="border:2px solid blue">border color example2</p>
</body>

</html>

Output: