Change Text Size with Internal or External CSS

Using separate CSS to select the required text and using the font-size property to change the font size. The size value can be set using length units or keywords like x-small, small or large. You can use a separte CSS file in similar way.

Syntax:

<style>
    p {
        font-size: large;
    }
</style>

Example: In this example, we will use separate CSS.

HTML
<html>

<head>
    <!-- Using CSS to change
  the font size -->
    <style>
        body {
            font-size: 60px;
        }

        p {
            font-size: xx-large;
        }
    </style>
</head>

<body>
    Perfect Portal for Geeky

    <p>Welcome to w3wiki</p>

</body>

</html>

Output:

changing the font size in HTML

Explanation:

  • In this example the body’s font size is set to 60px using the body selector.
  • The paragraph (p) element’s font size is specifically set to “xx-large” using the paragraph selector.
  • As a result, the paragraph “Welcome to w3wiki” appears larger than the surrounding text due to the applied font size.


How to change the font size in HTML ?

Changing the font size in HTML refers to adjusting the displayed text size on a webpage. This can be achieved inline using the style attribute within HTML tags, specifying a font-size property value, or globally by defining styles in CSS.

Table of Content

  • Change Text Size with HTML font Tag
  • Change Text Size with HTML big Tag
  • Change Text Size with Inline CSS
  • Change Text Size with Internal or External CSS

Similar Reads

Change Text Size with HTML font Tag

HTML tag can be used for making changes to the font that is enclosed within the tags. It has various attributes that can be used to specify the size, color, or face of the font. This tag was deprecated in HTML5, therefore this approach may not work in modern browsers....

Change Text Size with HTML big Tag

HTML tag can be used for increasing the font size by one level that is enclosed within the tags. It does not have any attributes. This tag was deprecated in HTML5, therefore this approach may not work in modern browsers....

Change Text Size with Inline CSS

Using the inline style attribute to change the font-size of the tag it is used on. The usage of this attribute overrides any style set globally....

Change Text Size with Internal or External CSS

Using separate CSS to select the required text and using the font-size property to change the font size. The size value can be set using length units or keywords like x-small, small or large. You can use a separte CSS file in similar way....