How to set text color & font style in HTML ? Last Updated : 17 May, 2023 Comments Improve Suggest changes Like Article Like Report In this article, we will learn how to set text color & font style in HTML. The <style> tag in HTML helps us to set the text color & font style in HTML. This modification includes changing font size, font family, font color, etc. Not only the text but also we can change the style of a body or part of a page. We can add style in different ways. Now let’s look at various attributes of style and what else the tag supports. Syntax: style="property: value;" Example: In this example, we will change the text color and font style of the first div i.e. class name container using <style> tag. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> * { margin: 0; padding: 0; } h1 { font-size: 1.8rem; } p { font-size: 1rem; padding: 1rem 0; } .container { color: blue; font-family: cursive; } </style> </head> <body> <!-- Section using styles --> <div class="container"> <h1>Welcome to GFG</h1> <p> Coding is the New Literacy and no one can deny this fact! And especially, when it comes to young ones or school students, investing the time & efforts in learning programming skill become more & more advantageous and rewarding. </p> </div> <!-- Section without styles --> <div> <h1>Welcome to GFG</h1> <p> Coding is the New Literacy and no one can deny this fact! And especially, when it comes to young ones or school students, investing the time & efforts in learning programming skill become more & more advantageous and rewarding. </p> </div> </body> </html> Output Example 2: In this example, we will use the style in the inline style attribute. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <h1 style="font-size:medium; color: rgb(0, 34, 128);"> Welcome to GFG </h1> <p style="color: green;"> Coding is the New Literacy and no one can deny this fact! And especially, when it comes to young ones or school students, investing the time & efforts in learning programming skill become more & more advantageous and rewarding. </p> </body> </html> Output: Comment More infoAdvertise with us Next Article How to set text color & font style in HTML ? G gurjeetsinghvirdee Follow Improve Article Tags : HTML HTML-Questions Similar Reads How to Style Text in HTML? The HTML style attribute adds styles to an element, such as color, font, size, and more. Here, we are going to learn how to style Text in HTML.These are the following methods:Table of ContentUsing CSS StylesUsing Element for StylingUsing CSS StylesThe <b> tag makes text bold, while <strong 2 min read How to Change the Font Size in HTML? Changing the font size in HTML helps control the readability and visual hierarchy of your content. Earlier, the <font> tag with the size attribute was commonly used for this purpose. However, with the introduction of HTML5, the <font> tag has been deprecated and is no longer recommended. 2 min read How to Change Font Color in HTML? We can use <font> tag to change the text color in HTML. This tag was used in older versions of HTML but is deprecated in HTML5. So we can use inline CSS as the best and quickest way to change the font color. 1. Change Font Color using <Font> tagThe <font> tag was used to change tex 2 min read How to Change Font-size and Color in HTML? To change the font-size and color in HTML, a style tag with color and font properties is used.1. Using Inline Style AttributeIn this approach, a style attribute is used in the tag for which we want to change the font size and color. Below are the properties that we will use inside the style attribut 2 min read How to Set Text Color in RGBA in Tailwind CSS ? In this article, we will change the color of text to rgba(0, 0, 0, 0.54) which is an RGB color format with an added parameter alpha that tells the opacity of the color. In this article, we are going to learn how we can achieve the text color of rgba(0, 0, 0, 0.54) in Tailwind CSS and hence, change t 3 min read Like