--- title: Dynamic font size description: The Dynamic Font Size utility scales an element’s base font size based on container width. --- Use Dynamic font size to scale the base font size of an element. Any element children using relative font sizes will scale proportionally. A [container element](/utils/container/) is required as a wrapper. There are set widths for the container where the scaling starts and stops. The scaling and width parameters may be controlled using modifer classnames as described below. The default values are a scaling factor of `1 – 1.25` between widths `400px – 750px`.

Dynamic font

This text will resize dynamically depending on the width of the containment context. Baseline font-size will go from 1em to 1.25em starting at 400px width up to 750px. The heading will also scale to a factor of 1.25, but starting at 1.25em it will scale up to 1.5625em.

Resize container (px) →

## Required markup A containment context is required. The easiest way to create one is to use the [container element](/utils/container/). The containment context determines the width from which the scaling of the dynamic font is calculated. Inside the container, place one or more dynamic font elements using class `env-dynamic-font`. Text inside these elements will be dynamically scaled, text outside will not. ```html noexample

This text will resize!

``` Note: When using [Envision for Dashboard Widgets](/dashboard/widget-typography/#dynamic-font-size-in-widgets), the container element is not required since the widget already is a containment context. ### Additional markup To not interfere with the width calculations, padding must be used on a separate element inside the container element. Elements placed inside the container but outside of `env-dynamic-font` will not scale. ```html noexample

This heading will not resize

This text will resize ...

``` ## Controlling the scaling ### Scaling factor Use modifer `env-dynamic-font--{scale}` where `{scale}` may be one of: `1_125`, `1_25`, `1_375`, `1_5`, `1_625`, `1_75`, `1_875`, `2` Default scaling factor is `1.25` which is identical to using the `1_25` modifer. _Note that dot is replaced by underscore as dot is not allowed in CSS class names._

Scaling factor

Scaling factor 1.125

Scaling factor 1.25 (default)

Scaling factor 1.375

Scaling factor 1.5

Scaling factor 1.625

Scaling factor 1.75

Scaling factor 1.875

Scaling factor 2

Resize container (px) →

```html noexample

Scaling factor 1.125

``` ### Scaling width boundaries The scaling will occur between two set widths. If the container width is smaller than the from-value, the scaling will be set to the lowest possible value and vice versa for the to-value. Boundaries are set using modifier classes `env-dynamic-font--from-{value}` and `env-dynamic-font--to-{value}`. Allowed **from** values: `250`, `300`, `350`, `400`, `450`, `500`, `550` Allowed **to** values: `500`, `550`, `600`, `650`, `700`, `750`, `800`, `900`, `1000` Default boundaries are from 400 to 750. Dynamic font scaling chart

Boundaries

From 250 to 500

From 400 to 650

From 550 to 800

Resize container (px) →

```html noexample

From 250 to 500

``` Note: When using [Envision for Dashboard Widgets](/dashboard/widget-typography/#dynamic-font-size-in-widgets), there are additional widget specific boundaries available. ### Downscaling The default is scaling up from `1 – 1.25`. Scaling may be reversed, so `1` is the highest factor by using the modifier `env-dynamic-font--downscale`. The lowest factor will then be `1 / {scale}`, which is `0.8` at default settings.

Upscaling vs downscaling

Upscaling factor 1.25 (default)

Upscaling factor 2

Downscaling factor 1.25

Downscaling factor 2

Resize container (px) →

```html noexample

Upscaling factor 1.25 (default)

Upscaling factor 2

Downscaling factor 1.25

Downscaling factor 2

``` ## CSS settings For higher precision in setting the values, the following CSS variables may be set. **Note!** Do not use any units. ```html noexample

Scaling factor 1.2345

``` ```css noexpand .example-custom-dynamic-font-settings { /* Scaling factor */ --env-dynamic-font-scale: 1.2345; /* Container from- and to widths (px) */ --env-dynamic-font-from-width: 357; --env-dynamic-font-to-width: 579; } ```