How To Change Size Of Text In Html

5 min read

How to Change Size of Text in HTML: A Complete Beginner's Guide

Learning how to change size of text in HTML is one of the first skills every aspiring web developer needs to master. Whether you want to make a heading stand out, shrink a disclaimer, or build a fully responsive typography system, the process is simple once you understand the modern approach. In this guide, you'll discover every practical method for adjusting text size, the units you should use, and the mistakes you should avoid.

Why Text Size Matters in Web Design

Text size affects readability, accessibility, and the overall visual hierarchy of a page. On top of that, when headings, paragraphs, and captions are sized correctly, visitors can scan content effortlessly. When they are sized poorly, even great content feels exhausting to read No workaround needed..

It's also worth noting that the old <font size="4"> tag is obsolete in HTML5. Modern browsers still render it, but it is no longer part of the standard, and relying on it will hurt your code quality and SEO Took long enough..

The Modern Way: CSS font-size

Today, text size is controlled with the CSS property font-size. You have three main ways to apply it.

1. Inline Styles

The fastest method is adding the style directly to an element:

This paragraph is 20 pixels tall.

Inline styles are handy for quick tests, but they become messy on large projects because every element must be edited individually It's one of those things that adds up. Nothing fancy..

2. Internal Stylesheet

Place your CSS inside a <style> block in the <head> section:


  

This keeps styling separate from content and applies to the whole page.

3. External Stylesheet

For real websites, store your CSS in a separate file (for example, styles.css) and link it:


Then in styles.css:

body {
  font-size: 16px;
}
h2 {
  font-size: 2rem;
}

This is the most professional approach because one file can control the typography of an entire site Practical, not theoretical..

Understanding Units of Measurement

Choosing the right unit is just as important as knowing the property. Here are the most common options:

  • Pixels (px) – absolute and predictable. font-size: 16px; always renders at 16 pixels.
  • Em (em) – relative to the parent element's size. One em equals the parent's font size, so values can compound in nested elements.
  • Rem (rem) – relative to the root element (<html>). This is the recommended unit for scalable, accessible design.
  • Percentage (%) – relative to the parent, similar to em.
  • Viewport units (vw, vh) – relative to the browser window, useful for fluid, responsive typography.

A Quick Comparison

html { font-size: 16px; }

small  { font-size: 0.Also, 875rem; } /* 14px */
. medium { font-size: 1rem; }     /* 16px */
.That's why large  { font-size: 1. 5rem; }   /* 24px */
.

Using **rem** keeps everything proportional, so when you adjust the root size, the entire layout scales gracefully.

## Using Headings to Change Text Size

HTML provides six heading levels, each with a default size:

1. `

` – largest, usually around 2em 2. `

` 3. `

` 4. `

` 5. `

` 6. `
` – smallest ```html

This is a large heading

This is a small heading

Headings are perfect when size differences reflect content structure, not just decoration. Search engines also use them to understand your page, so never choose a heading level based only on how big it looks.

Step-by-Step Example

Let's put it all together in a complete file:




  


  

Main Page Title

This introductory paragraph uses a slightly larger size to draw attention.

Section Heading

Body text stays at the base 1rem (16px by default), ensuring comfortable reading.

Legal disclaimer or copyright notice appears smaller without breaking hierarchy.

Responsive Typography with clamp()

Modern CSS lets you create fluid type that scales smoothly between a minimum and maximum size without media queries:

h1 {
  font-size: clamp(2rem, 5vw + 1rem, 4rem);
}
  • Minimum: 2rem (never smaller)
  • Preferred: 5vw + 1rem (scales with viewport)
  • Maximum: 4rem (never larger)

This technique delivers readable headings on everything from phones to ultrawide monitors.

Accessibility Checklist

  • Use relative units (rem/em) so users can resize text via browser settings.
  • Maintain a base size of at least 16px for body copy.
  • Ensure sufficient contrast between text and background (WCAG AA: 4.5:1 for normal text).
  • Avoid disabling zoom with user-scalable=no in the viewport meta tag.
  • Test at 200% zoom to confirm layout doesn't break or clip content.

Common Pitfalls to Avoid

Mistake Why It Hurts Fix
Sizing everything in px Prevents user scaling, breaks responsive layouts Switch to rem for global sizing
Using headings out of order (h3 before h2) Confuses screen readers and SEO Follow semantic hierarchy
Setting font-size: 0 to hide text Content disappears for assistive tech Use visually-hidden utility class instead
Overusing vw units alone Text becomes unreadably small on mobile Combine with clamp() or rem fallback

Quick note before moving on.

Conclusion

Controlling text size in HTML is fundamentally about separation of concerns: keep structure in HTML, presentation in CSS, and choose units that respect both the designer's intent and the user's needs. Start with a sensible rem-based scale, layer in fluid clamp() headlines for impact, and always verify the result at different zoom levels and viewport widths. When typography scales gracefully, your content remains readable, accessible, and professional—no matter the device.

Not obvious, but once you see it — you'll see it everywhere.

Just Finished

Fresh from the Desk

Dig Deeper Here

Keep Exploring

Thank you for reading about How To Change Size Of Text In Html. We hope the information has been useful. Feel free to contact us if you have any questions. See you next time — don't forget to bookmark!
⌂ Back to Home