# Set the Body Text Size and Line Height

> Sets the default font size and line height of body text in a block theme through theme.json, for more comfortable reading on every page.

- Type: PHP
- Runs: Run everywhere
- Category: [Block Editor](https://wpide.com/library/category/gutenberg/)
- Tags: theme-json, typography, readability
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/themejson-body-typography/

## Code

```php
// Body text settings.
$wpide_body_font_size   = 'clamp(1rem, 0.95rem + 0.25vw, 1.125rem)';
$wpide_body_line_height = '1.65';

add_filter( 'wp_theme_json_data_theme', function ( $theme_json ) use ( $wpide_body_font_size, $wpide_body_line_height ) {
    return $theme_json->update_with( array(
        'version' => WP_Theme_JSON::LATEST_SCHEMA,
        'styles'  => array(
            'typography' => array(
                'fontSize'   => $wpide_body_font_size,
                'lineHeight' => $wpide_body_line_height,
            ),
        ),
    ) );
} );
```

## Notes

A clamp() size scales between phones and desktops; use a fixed value like 18px if you prefer.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Set the Body Text Size and Line Height" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
