All TalkersCode Topics

Follow TalkersCode On Social Media

How To Change Font Color In Html

Last Updated : Jul 1, 2023

How To Change Font Color In Html

In this tutorial we will show you how to change font color in HTML, font color, which is known as text color in HTML is black by default, we can change this color to any other color with help of some specific tags and CSS.

Font color is sometimes used to convey meaning beyond the basic text. After this we understand some examples in which we use different ways to change font color.

Step By Step Guide On How To Change Font Color In HTML :-

By Using Style Attribute

The style attribute in used to change color of fonts in HTML. Here, the style attribute may be used as inline, internal and external CSS.

The style attribute is used with any tag like paragraph, heading and division and any other to deliver colors to fonts. Now, let us understand how to change color with help of some codes

<!DOCTYPE html>
          <title> Title of the document<title>
            <!-- example: to give any color to paragraph tag -->
	    <p style="color: red;">
      		  the text written in paragraph tag is in red color.
	    <!-- example: to give any color to heading tag -->
    <!-- the heading tag used here is of any form h1 to h6  -->
	    <h3 style="color: yellow";>
        the text written in heading tag is in yellow color.
    <!-- example to give any color to division tag -->
    <div style="color: blue;">
        the text written in division tag is in blue color.
  1. First, we write <! DOCTYPE html> which we used as an instruction to the web browser about what version of HTML file is written in.
  2. Secondly, the <html> tag is used to indicate the beginning of an HTML document.
  3. As above now <head> tag is used to contain information about web page. In this tag a <title> tag is used which helps us to specify a webpage title. Both <head> and <title> tags are Paired tags. So, both have </head> and </title> ending tags respectively.
  4. Thirdly, <body> tag is used to define the webpage body. All the contents to show on website are written here. Here we use paragraph, h3 and division tags. In all of them, we use style attribute
  5. And in style attribute, we give a color css in it, the value of color is red, yellow and blue, which is different to all the tags, now we open this code on browser we saw three different lines with three different colors.
  6. At last, the <body> and <html> tags are closed with </body> and </html> respectively.

Conclusion :-

At the end, we can say that to font color is an attractive way to display a webpage and seems to be eye catching.

We can change the font color of text written in any tag with the help of CSS. We can also use any type of CSS. But, color: value (here value is used as name of color) is most important thing to use different colors.

I hope this tutorial on how to change font color in HTML helps you.