Which CSS Property Controls the Text Size ?.

When it comes to styling web pages with CSS (Cascading Style Sheets), one of the most common tasks is adjusting the size of text elements. The ability to control text size is crucial for achieving the desired look and readability of a website. In this comprehensive guide, we will explore the CSS properties and techniques that allow you to precisely control the text size in your web projects.

The CSS Property: font-size

The primary CSS property responsible for controlling text size is font-size. This property allows you to set the size of text within an HTML element. You can specify the size in various units, including pixels (px), ems (em), percentages (%), or keywords such as small, medium, or large.

/* Using font-size in pixels */
p {
  font-size: 16px;

/* Using font-size in ems */
h1 {
  font-size: 2em;

/* Using font-size in percentages */
h2 {
  font-size: 150%;

/* Using font-size with keywords */
h3 {
  font-size: large;

The example above demonstrates how to use the font-size property with different units. You can apply it to various HTML elements to customize text sizes throughout your website.

Relative Units: ems and Percentages

Two commonly used relative units for specifying text size are ems (em) and percentages (%). These units allow you to create flexible and responsive designs that adapt to the user’s preferences and device screen sizes.

1. ems: The em unit is a relative measurement based on the font size of the parent element. If the parent element has a font size of 16px, and you set an element’s font size to 1em, it will be equivalent to 16px. Using ems is useful for creating scalable and consistent designs.

which css property controls the text size

2. percentages: Specifying text size in percentages is relative to the font size of the parent element as well. If the parent element’s font size is 16px, setting an element’s font size to 150% would result in 24px (1.5 times the parent’s font size). This approach is beneficial for creating responsive layouts.

Keywords for Common Text Sizes

In addition to numerical values and relative units, CSS also provides keywords for common text sizes. These keywords include:

  • small: Renders text at a smaller size.
  • medium: The default text size (usually equivalent to 16px).
  • large: Renders text at a larger size.
  • x-large: Renders text larger than large.
  • xx-large: Renders text even larger than x-large.
  • smaller: Makes text one size smaller than the parent’s font size.
  • larger: Makes text one size larger than the parent’s font size.

Using these keywords can be a quick way to apply consistent text sizes throughout your website without specifying exact measurements.

Viewport Units for Responsive Text

If you want to create text that scales with the viewport size (the size of the user’s browser window), you can utilize viewport units: vw (viewport width) and vh (viewport height). These units are particularly useful for making your text responsive on various devices.

/* Responsive text that scales with viewport width */
p {
  font-size: 5vw;

/* Responsive text that scales with viewport height */
h1 {
  font-size: 10vh;

In the example above, the text size will adjust based on the width or height of the viewport, making it a versatile choice for responsive design.

Additional CSS Properties for Text Sizing

While font-size is the primary property for controlling text size, several other CSS properties can also influence text appearance:

  • font-family: Specifies the typeface or font family for the text.
  • font-weight: Determines the thickness or boldness of the text.
  • line-height: Sets the spacing between lines of text, affecting readability.
  • text-transform: Changes the capitalization of text (e.g., uppercase, lowercase).
  • letter-spacing: Adjusts the space between characters.
  • text-decoration: Adds decorations like underline or strikethrough to text.

By combining these properties, you can fine-tune the appearance of text on your website to match your design preferences.


In summary, the CSS property font-size is the primary controller of text size in web development. You can use numerical values, relative units, percentages, keywords, and even viewport units to set text size according to your design and responsiveness requirements. Additionally, CSS offers other properties to further style and customize text appearance on your website.

By mastering text size control with CSS, you can create visually appealing and user-friendly web pages that cater to your audience’s preferences and enhance the overall user experience.

External Links – which css property controls the text size

Internal Links

Feel free to explore the external links for related content, and use the internal links for easy navigation within this comprehensive guide on text sizing in CSS.

For more in-depth knowledge and resources on CSS and text size control, you can explore the following external websites:

  • W3Schools CSS Fonts: W3Schools offers a comprehensive tutorial on CSS fonts, including the font-size property and its usage.
  • MDN Web Docs – font-size: The Mozilla Developer Network (MDN) provides detailed documentation on the font-size property, complete with examples and explanations.
  • CSS-Tricks Font-Size Property: CSS-Tricks offers valuable insights and practical tips on using the font-size property effectively in your web projects.

These external resources can further enhance your understanding of CSS text sizing and help you master this essential aspect of web design.

Retour en haut