How to deal with Color in HTML

In this article I explain how to apply colors in HTML.
  • 1944

Foreground Color

In order to add color in the HTML element we use <style="color: {color_name}">.

HTML code:

<html>

<head>

    <title>HTML Example</title>

</head>

<body>

    <h1 style="color: Blue">

        Hi!Have a nice day!!!!!</h1>

</body>

</html>

 

Output

Hi!Have a nice day!!!!!

Background Color

In order to add color in the background of HTML text the element that we use is <style="backgroung-color:{color_name}">.

HTML code:

<html>

<head>

    <title>HTML Example</title>

</head>

<body>

    <h1 style="background-color: Blue">

        Hi!Have a nice day!!!!!</h1>

</body>

</html>

 

Output

Hi!Have a nice day!!!!!

Border Color

In order to add color in the border of the HTML element we use <style="border:{color_name}">.

HTML code:

<html>

<head>

    <title>HTML Example</title>

</head>

<body>

    <h4 style="border: 1px solid blue">

        Hi!Have a nice day!!!!!</h4>

</body>

</html>

 

Output

Hi!Have a nice day!!!!!

Ask Your Question 
 
Got a programming related question? You may want to post your question here
 

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.