Open In App

How to Style Text in HTML?

Last Updated : 30 Jul, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

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:

Using CSS Styles

The <b> tag makes text bold, while <strong> adds semantic importance, typically displaying as bold by default. Incorporating these tags improves readability and user engagement. The <p> tags enclose paragraphs of text, while inline styles defined with the style attribute modify their appearance. By specifying properties like color and font size directly within the tag, precise styling adjustments are achieved without the need for external CSS files.

Example: The example shows the above-explained approach.

HTML
<!DOCTYPE html>
<html>

<body>

    <p>I am normal</p>
    <p style="color:red;">I am red</p>
    <p style="color:blue;">I am blue</p>
    <p style="font-size:50px;">I am big</p>
    <p>Hello <b>GFG</b></p>
</body>

</html>

Output:

Screenshot-(232)
Using inline css

Using Element for Styling

  • <strong> is used to semantically indicate strong importance.
  • <em> is used to semantically indicate emphasis.
  • <u> is used to underline text.
  • <b> is used for bold text styling, similar to <strong> but carries no semantic meaning.

Example: The example shows the above-explained approach.

HTML
<!DOCTYPE html>
<html>

<body>

    <p>I am normal</p>
    <p><strong>I am strong</strong></p>
    <p><em>I am emphasized</em></p>
    <p><u>I am underlined</u></p>
    <p style="color:red;">I am red</p>
    <p style="color:blue;"><b>I am blue and bold</b></p>
    <p style="font-size:50px;">I am big</p>
    <p>Hello <b>GFG</b></p>

</body>

</html>

Output:

Screenshot-(235)
Using internal styling

Next Article
Article Tags :

Similar Reads