Favorites

CSS <relative-size> Data Type

<relative-size>
CSS Data TypeThis data type is supported by all modern browsers.
Updated 21st November 2026

The <relative-size> data type is the keyword larger or smaller, which makes the font size one step larger or smaller than the parent's.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

Description

The <relative-size> CSS data type represents a value that is defined in relation to another length, typically the font size of the element itself or its parent. It is primarily used in typographic properties, allowing text or other elements to scale proportionally rather than using fixed units like pixels or points. Using <relative-size> ensures that designs remain more flexible and accessible, especially when users adjust their default font size in the browser.

This data type is used by the font-size property and the font shorthand. It has exactly two values: the keywords larger and smaller, which move one step up or down the font size scale relative to the parent element. For example, setting font-size: larger; increases the text size relative to its parent, while smaller decreases it. This makes it particularly useful in responsive design, where content must adapt to different screen sizes and user preferences.

An important distinction is that <relative-size> differs from <length> or absolute units like pixels, because it does not define a fixed measurement. Instead, it relies on context, which means that the same keyword can result in different computed sizes depending on the surrounding elements. Each step is roughly a factor of 1.2, the same ratio as the steps between the <absolute-size> keywords, although browsers may round to the nearest keyword size. For precise control, use em or percentage values instead.

Here are a few examples:

/* Increase the font size relative to the parent */
p {
    font-size: larger;
}

/* Decrease the font size relative to the parent */
small {
    font-size: smaller;
}

/* Nested relative sizing */
div {
    font-size: larger;
}

div p {
    font-size: smaller; /* relative to the div's larger size */
}

The use of <relative-size> promotes scalability and readability while maintaining a relationship between nested elements, making it a core tool in adaptive typography and fluid design systems.

Interactive Demo

Parent text (16px) span nested span nested again

Demo Code
HTML Code
<p class="demo-rel">Parent text (16px) <span class="demo-element">span <span>nested span <span>nested again</span></span></span></p>
CSS Code
.demo-rel {
	width: 290px;
	margin: 0;
	font-size: 16px;
	line-height: 1.6;
	color: #1b1f3b;
}
.demo-element, .demo-element span {
	color: #f72585;
	font-weight: bold;
	font-size: smaller;
}

Syntax

<relative-size> = smaller | larger

Values

  • smallerA relative size one size smaller than the inherited size.
  • largerA relative size one size larger than the inherited size.

Example

<div class="wrap">
<h1>CSS &lt;relative-size&gt; examples</h1>
<div class="card" style="font-size: 16px">
<p>Base text, 16px</p>
<div class="level up">
<p>font-size: larger <code>(one step up)</code></p>
<div class="level up">
<p>font-size: larger again <code>(two steps up)</code></p>
</div>
</div>
<div class="level down">
<p>font-size: smaller <code>(one step down)</code></p>
<div class="level down">
<p>font-size: smaller again <code>(two steps down)</code></p>
</div>
</div>
</div>
<p class="note">Each nested level is larger or smaller than its parent.</p>
</div>
/* Base demo layout */
* { box-sizing: border-box; }

body {
  margin: 24px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  background: #f5f7fb;
  color: #102a43;
}

.wrap {
  max-width: 860px;
  margin: 0 auto;
}

h1 {
  font-size: 20px;
  margin: 0 0 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 6px 18px rgba(16, 42, 67, 0.08);
}

.label {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 12px;
  color: #486581;
  margin-top: 10px;
  word-break: break-word;
}

.note {
  font-size: 13px;
  color: #486581;
  margin-top: 14px;
}

/*  examples */
.level {
  margin: 0;
  padding: 6px 0 6px 14px;
  border-left: 3px solid #93c5fd;
}

.level p {
  margin: 0 0 6px;
}

.up { font-size: larger; }
.down { font-size: smaller; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 12px;
  color: #486581;
}
Open in editor

Browser Support

The following information will show you the current browser support for the CSS relative-size data type. Hover over a browser icon to see the version that first introduced support for this CSS data type.

This data type is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.