VOOZH about

URL: https://www.geeksforgeeks.org/css/foundation-css-global-style-font-sizing/

⇱ Foundation CSS Global Style Font Sizing - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Foundation CSS Global Style Font Sizing

Last Updated : 23 Jul, 2025

Foundation CSS offers a global font scaling strategy that enables web developers to specify uniform font sizes across their websites. It is a front-end framework that offers a library of pre-built components, styles, and templates. Foundation CSS's global style font scaling method allows developers to specify font sizes for all components, including headings, paragraphs, and other text elements, in one location. This helps to maintain uniformity and coherence throughout the page and makes future font size adjustments easy.

Syntax: Foundation CSS font sizing uses a simple syntax that is easy to understand and implement. The syntax for setting the font size for all elements is:

$global-font-size: XXpx;

Properties: There are several properties that can be set using Foundation CSS global style font sizing, including:

  • $global-font-size: This property sets the font size for all elements on the website.
  • $h1-font-size, $h2-font-size, $h3-font-size, $h4-font-size, $h5-font-size, $h6-font-size: These properties set the font size for the different heading levels.
  • $small-font-size: This property sets the font size for small elements, such as captions or labels.
 

Features: Foundation CSS global style font scaling has a number of characteristics that make it a great option for website developers, such as:

  • Design consistency: By using global style font scaling, website developers may make sure that all of the elements have the same font size, which contributes to a design that is consistent.
  • Accessibility: By using standard font size, website designers may increase the website's accessibility and make it simpler for visitors with visual impairments to read and navigate the material.
  • Time-saving: By removing the need to manually specify font sizes for each individual website element, Foundation CSS's global style font scaling saves time. This frees up developers to concentrate on the layout and functionality of the design.

Approach: The global style font scaling solution given by Foundation CSS entails specifying font sizes for many text components in a single location. This may be accomplished by specifying font-size variables in a separate file, such as variables.scss or foundation.scss. These variables can then be referenced in CSS files where font sizes must be specified.

For example, the variables.scss file may contain the following code:

$global-font-size-xxl: 36px;
$global-font-size-xl: 30px;
$global-font-size-lg: 24px;
$global-font-size-md: 18px;
$global-font-size-sm: 14px;
$global-font-size-xs: 12px;

Example 1:

Output:

👁 Image
 

We've incorporated Foundation CSS via a CDN (content delivery network) in this example to avoid having to download and host the CSS ourselves. With the style tag, we have also added some custom CSS that applies the global font size variables to various HTML components. To apply various font sizes to different heading levels and paragraphs, we utilized the variables $global-font-size-xxl, $global-font-size-xl, and $global-font-size-lg. Here is a fantastic example of how you can utilize Foundation CSS's global font scaling to keep your typography consistent across your website.

Example 2: In this example, we've defined some custom classes in our CSS that apply the global font size variables to different classes. We've then used these classes in our HTML to apply the appropriate font size to different elements.

Output:

👁 Image
 

This is a good example of how you can use Foundation CSS's global font sizing to create your own custom typography classes that can be used throughout your website.

Comment