Skip to main content

DEFAULT_FONT_SIZE

Constant DEFAULT_FONT_SIZE 

Source
pub const DEFAULT_FONT_SIZE: f32 = 16.0;
Expand description

Default/fallback font size in pixels, used when no font-size is specified.

This is the same as the CSS “medium” keyword and matches browser defaults:

  • CSS 2.1 §15.7: “medium” is the user’s preferred font size
  • All major browsers default to 16px
  • W3C HTML5: The default font-size of the root element is 16px

This constant is used in two scenarios:

  1. As fallback when no explicit font-size is found in the cascade
  2. In legacy to_pixels() for em/rem conversion when no context available

Research:

  • Chrome/Firefox/Safari: 16px default
  • CSS font-size keywords: medium = 16px (derived from 13.33px * 1.2)
  • Can be overridden by user preferences (browser settings)