WordPress

What Is the HTML for Fonts in WordPress?

WordPress has no font tag: core prints @font-face rules from theme.json and the Font Library. See the real output and how to self-host fonts.

Shashank Dubey
·11 min read
Type specimen next to the @font-face rule WordPress prints in the wp-fonts-local style block

There is no HTML tag for fonts in modern WordPress. The old <font> element is obsolete, and WordPress never uses it. Fonts are set with CSS: an @font-face rule loads the font file, and a font-family declaration applies it. In current WordPress the HTML you will actually find is a <style class="wp-fonts-local"> block in the page head, printed by core from your theme’s theme.json and from the Font Library, plus CSS variables such as --wp--preset--font-family--manrope.

Our team checked everything on this page against WordPress 7.1.4, the current release, on 18 November 2026. The output samples come from a clean install running Twenty Twenty-Five, and every function and filter name was confirmed in the core source.

This page has no recorded Search Console queries yet, so the headings follow the questions people ask when they open the inspector, see a font they did not choose, and want to know where it came from.

Is there an HTML tag for fonts in WordPress?

No. The HTML <font face="Arial"> tag belongs to the 1990s web. The HTML Standard lists it as obsolete, and nothing in WordPress core, the block editor or any default theme writes it. If you paste it into a post, the block editor may keep it, but you are fighting the platform.

HTML describes what content is: a heading, a paragraph, a link. CSS describes how it looks, typeface included. So “the HTML for fonts” in WordPress really means three pieces of front-end code that work together:

  1. An @font-face rule that tells the browser a font name and where its file lives.
  2. A font-family declaration that applies that name to elements, usually through a CSS variable.
  3. A class or inline style on a block, when an editor picks a font for one heading or paragraph.

The rest of this guide shows where each piece comes from and how to control it.

What font HTML does WordPress print in the page head?

Since WordPress 6.4, core has a Font Face API. On every front-end page, the wp_print_font_faces() function runs on wp_head at priority 50, collects every font face defined in your theme and in the Font Library, and prints them in one style block. Here is the exact output for Twenty Twenty-Five, with only the domain changed:

<style class="wp-fonts-local">
@font-face{font-family:Manrope;font-style:normal;font-weight:200 800;font-display:fallback;src:url('https://example.com/wp-content/themes/twentytwentyfive/assets/fonts/manrope/Manrope-VariableFont_wght.woff2') format('woff2');}
@font-face{font-family:"Fira Code";font-style:normal;font-weight:300 700;font-display:fallback;src:url('https://example.com/wp-content/themes/twentytwentyfive/assets/fonts/fira-code/FiraCode-VariableFont_wght.woff2') format('woff2');}
</style>

A few details in that output matter in practice:

  • The class wp-fonts-local is your signpost. Search the page source for it and you see every font core loads. If a font is missing from this block, core is not loading it.
  • font-display defaults to fallback. That is the value in WP_Font_Face when a theme does not set one. Core accepts auto, block, fallback, swap and optional; anything else is replaced with the default.
  • The files are on your own domain. Theme fonts load from the theme folder. Nothing here contacts Google or any other font service.
  • Nothing is preloaded. Core prints the rules but no <link rel="preload"> tags. The browser discovers each file only when the CSS needs it. We cover adding a preload below.

Where does the font-family part come from?

The @font-face rules only make fonts available. Applying them happens in the global styles stylesheet, which core also generates from theme.json. For every font family, it creates a CSS variable and a utility class:

:root {
  --wp--preset--font-family--manrope: Manrope, sans-serif;
  --wp--preset--font-family--fira-code: "Fira Code", monospace;
}

.has-manrope-font-family {
  font-family: var(--wp--preset--font-family--manrope) !important;
}

When an editor picks a font for one block, the block gets the has-{slug}-font-family class in its HTML, for example <p class="has-manrope-font-family">. Site-wide choices go into the same stylesheet as rules on body and on elements such as headings, using the variable rather than the raw font name.

That variable is the reason you should reference fonts in your own CSS as var(--wp--preset--font-family--manrope) and not as Manrope. Change the font in Styles later and every rule follows.

How do theme.json fontFamilies and fontFace work?

In a block theme, fonts are declared in theme.json under settings.typography.fontFamilies. Each family has a display name, a slug (used in the CSS variable and class), the CSS fontFamily stack, and an optional fontFace array that describes the files. Here is a minimal, valid example for a self-hosted variable font:

{
  "$schema": "https://schemas.wp.org/trunk/theme.json",
  "version": 3,
  "settings": {
    "typography": {
      "fontFamilies": [
        {
          "name": "Inter",
          "slug": "inter",
          "fontFamily": "Inter, sans-serif",
          "fontFace": [
            {
              "fontFamily": "Inter",
              "fontStyle": "normal",
              "fontWeight": "300 900",
              "fontDisplay": "swap",
              "src": [ "file:./assets/fonts/inter/Inter-VariableFont.woff2" ]
            }
          ]
        }
      ]
    }
  },
  "styles": {
    "typography": {
      "fontFamily": "var:preset|font-family|inter"
    }
  }
}

Four rules keep this working:

  • file:./ means “relative to the theme folder”. Core turns it into a full theme URL. In a child theme it resolves against the child theme, so ship the font file there too.
  • Keys are camelCase in JSON. fontWeight, fontStyle, fontDisplay. Core converts them to the kebab-case CSS properties when it prints the rule.
  • A range covers a variable font. "fontWeight": "300 900" declares one file for every weight in that range. Static fonts need one fontFace entry per weight and style.
  • Declaring is not applying. The styles section sets the font as the site default. Without it, the font appears in the editor’s font picker but is not used until someone chooses it.

The official typography settings reference in the Theme Handbook lists every option, including font sizes and fluid typography.

What is the WordPress Font Library?

The Font Library arrived in WordPress 6.5. It is to fonts what the Media Library is to images: a place to upload font files, install fonts from Google Fonts, and switch individual weights on or off without editing code. Since WordPress 7.0 it has its own screen under Appearance > Fonts and works with classic themes as well as block themes, according to the Font Library documentation (updated July 2026).

Under the hood it does four things, all visible in core:

Piece

What core does

Where to look

Font records

Each family is a wp_font_family post; each file is a wp_font_face post

wp-includes/post.php

Font files

Saved to wp-content/uploads/fonts/, changeable with the font_dir filter

wp_get_font_dir()

Allowed uploads

.ttf, .otf, .woff and .woff2 only

WP_Font_Utils

Activation

Turning a weight on saves it to your global styles, so it joins the theme fonts in wp-fonts-local

Styles > Typography

Collections

A “Google Fonts” collection is registered by default; plugins can add their own with wp_register_font_collection()

wp-includes/fonts.php

The practical result: a font installed through the library ends up in exactly the same <style class="wp-fonts-local"> block as your theme fonts, pointing at a file in your uploads folder. There is no separate HTML for library fonts.

Does installing Google Fonts from the library send visitor data to Google?

No, and this is the most useful thing to know about the library. The first time you open the Install Fonts tab, WordPress asks you to “Allow access to Google Fonts” and explains that the fonts you install will be downloaded from Google and stored on your site. Your browser (the admin’s) contacts Google while you browse and install. Your visitors never do: the files are copied to wp-content/uploads/fonts/ and served from your domain.

The permission is stored in your browser’s local storage, not in the database, so another admin on another computer sees the prompt again. You can revoke it from the three-dot menu on the same tab.

Should I host Google Fonts locally for privacy?

If your site has visitors in the EU, yes, and it also tends to be faster. When a page links to fonts.googleapis.com, every visitor’s browser requests the font from Google, which sends Google their IP address. In January 2022 the Munich Regional Court (LG München I, 3 O 17493/20) awarded a site visitor 100 euros in damages because a site did exactly that without consent. A German chamber of commerce notice on the ruling describes the wave of 100 to 170 euro demand letters that followed and recommends storing fonts on your own server.

We are not lawyers, and this is not legal advice. The technical fix, though, is simple and has no downside: serve the files from your own domain.

How the font loads

Visitor contacts Google?

What to do

Theme fonts in theme.json

No

Nothing

Font Library, including its Google Fonts tab

No (files copied to your site)

Nothing

Theme or plugin enqueues fonts.googleapis.com

Yes

Switch the option off, or self-host

Page builder “Google Fonts” setting

Usually yes, unless it has a “load locally” option

Turn on local loading

CSS @import of a Google URL

Yes

Replace with a local @font-face

To find out where you stand, load a page with the browser’s Network tab open, filter by “Font”, and look at the domain column. Or check the HTML from the command line (checked on 18 November 2026):

curl -s https://example.com/ | grep -oE "fonts\.(googleapis|gstatic)\.com[^\"' )]*" | sort -u

No output means the page HTML does not reference Google Fonts. Fonts injected later by JavaScript will not show up here, so confirm in the Network tab as well. If you use a Content Security Policy, a self-hosted setup also lets you keep font-src at 'self'; our guide to WordPress security headers covers that header.

How do I add a custom font in WordPress?

Pick the route that matches your theme and how much control you want.

Route

Best for

Code needed

Appearance > Fonts (Font Library)

Site owners, block or classic theme on WordPress 7.0+

None

theme.json fontFamilies

Theme and child theme developers

JSON only

Enqueued stylesheet with @font-face

Classic themes without theme.json

A few lines of PHP and CSS

Theme options panel

Themes with their own typography settings

None, but check where files load from

With the Font Library

  1. Go to Appearance > Fonts.
  2. Open Upload to add your own .woff2 file, or Install Fonts to pick from Google Fonts after granting access.
  3. Choose the weights you need. Every weight you activate is another file a visitor may download, so keep it to two or three.
  4. Apply the font: in a block theme, Appearance > Editor > Styles > Typography; in a classic theme, use the theme’s typography settings or reference the CSS variable in your CSS.

In a classic theme, with code

Put the font file and a small stylesheet in your child theme, then enqueue the stylesheet on the front end and in the editor so both match:

<?php
// Classic theme: load a self-hosted font stylesheet on the front end and in the editor.
add_action( 'wp_enqueue_scripts', 'twp_enqueue_fonts' );
add_action( 'enqueue_block_editor_assets', 'twp_enqueue_fonts' );

function twp_enqueue_fonts() {
	wp_enqueue_style(
		'twp-fonts',
		get_theme_file_uri( 'assets/fonts/fonts.css' ),
		array(),
		wp_get_theme()->get( 'Version' )
	);
}
/* assets/fonts/fonts.css, paths are relative to this file */
@font-face {
	font-family: "Inter";
	font-style: normal;
	font-weight: 300 900;
	font-display: swap;
	src: url("inter/Inter-VariableFont.woff2") format("woff2");
}

body {
	font-family: "Inter", system-ui, sans-serif;
}

Relative url() paths in a stylesheet resolve against the stylesheet’s own location, which is why the CSS points at inter/ and not at a full theme path.

How do I make WordPress fonts load faster?

Fonts are often the largest render-blocking resource after your CSS. These changes give the biggest return:

  • Use WOFF2 only. Every current browser supports it, and it is the smallest format. Twenty Twenty-Five ships its fonts as WOFF2 only.
  • Prefer one variable font over several static files. Twenty Twenty-Five covers weights 200 to 800 with a single Manrope file.
  • Activate fewer weights. Each active weight in the library can be another download.
  • Set fontDisplay on purpose. swap shows fallback text at once and swaps when the font arrives; optional avoids the swap entirely on slow connections; core’s fallback sits between them.
  • Preload the one font used above the fold. Core does not do this for you.

A preload is one line in the head. The crossorigin attribute is required for fonts even on the same domain, or the browser downloads the file twice (checked on 18 November 2026):

<?php
// Preload the one font file used above the fold. Core does not preload fonts for you.
add_action( 'wp_head', function () {
	printf(
		'<link rel="preload" href="%s" as="font" type="font/woff2" crossorigin>' . "\n",
		esc_url( get_theme_file_uri( 'assets/fonts/inter/Inter-VariableFont.woff2' ) )
	);
}, 1 );

Preload only one or two files. Preloading every weight competes with your CSS and images for bandwidth and can make the page slower. For the wider picture, our guide on how to remove render-blocking CSS and JS covers the rest of the critical path.

How do I see which fonts a page actually loads?

The page source tells you what was requested. The browser tells you what was used, and the two often differ, because a font that fails to load falls back without any visible error. Three checks settle it:

  1. Rendered font. Right-click a piece of text, choose Inspect, open the Computed tab and scroll to the bottom. Chrome and Edge list “Rendered Fonts” with the real font name and how many glyphs used it. If it says Arial or Times while your CSS says Inter, the file did not load.
  2. Network. Reload with the Network tab open and filter by Font. Every row shows the file, its domain and its status. A red row or a 404 is your answer, and the domain column shows any request still going to a third party.
  3. Console. The browser’s FontFaceSet API lists every face it knows about and whether it loaded. Paste this into the console on any page (checked on 18 November 2026):
[...document.fonts].map((f) => `${f.family} ${f.weight} ${f.style}: ${f.status}`);

Faces marked unloaded are declared but not used on this page yet, which is normal. Faces marked error failed to download, which is not. Compare the list with the wp-fonts-local block in the source: a family that appears in neither place is coming from a plugin, a page builder or an @import inside another stylesheet.

One more source catches people out. Some plugins and themes print their own <link> tags for fonts in the head, outside the core block. Search the page source for .woff2 and fonts. to find every one of them in a few seconds.

How do I control or turn off the Font Library?

Agencies and stores with a fixed brand often want editors to stop adding fonts. These snippets go in a child theme or a small plugin, and each was run on our WordPress 7.1.4 test site.

Remove only the Google Fonts tab

<?php
// Remove the Google Fonts collection from the Font Library (uploads still work).
add_action( 'init', function () {
	wp_unregister_font_collection( 'google-fonts' );
}, 20 );

Uploads keep working. The collection is registered on init at the default priority, so the removal runs later, at 20.

Hide the Font Library

<?php
// Hide the Font Library inside the Site Editor's Styles panel.
add_filter( 'block_editor_settings_all', function ( $settings ) {
	$settings['fontLibraryEnabled'] = false;
	return $settings;
} );

// Hide the Appearance > Fonts screen added in WordPress 7.0.
// The URL still opens for users with edit_theme_options.
add_action( 'admin_menu', function () {
	remove_submenu_page( 'themes.php', 'font-library.php' );
}, 999 );

The first filter is the method published on the WordPress Developer Blog and hides the library in the Site Editor. It does not touch the Appearance > Fonts screen that WordPress 7.0 added, which is why the second part is needed. Removing a menu item is not a permission check: anyone with the edit_theme_options capability can still open the screen by URL. If that matters, control who has that capability.

Store font files somewhere else

<?php
// Store Font Library uploads in wp-content/uploads/brand-fonts instead of /fonts.
add_filter( 'font_dir', function ( $font_dir ) {
	foreach ( array( 'path', 'url', 'basedir', 'baseurl' ) as $key ) {
		$font_dir[ $key ] = preg_replace( '#/fonts$#', '/brand-fonts', $font_dir[ $key ] );
	}
	return $font_dir;
} );

This uses the font_dir filter that core applies inside wp_font_dir(), so uploads, deletions and the printed URLs all move together. Run it before any fonts are installed, or move the existing files yourself.

Common mistakes people report

These come up repeatedly in the WordPress.org forums and the Gutenberg issue tracker. We paraphrase each one and link the source. Checked on 18 November 2026.

  • The font works in one browser and not in others. A site owner’s Noto Sans showed in Opera and Edge but not in Chrome or Firefox; the console showed the font files were served over HTTP on an HTTPS site and blocked as mixed content. Setting both site addresses to HTTPS, replacing old http:// URLs and reinstalling the font fixed it. (WordPress.org support thread)
  • A custom @font-face rule silently falls back. In another thread, one font failed for the same HTTP reason and a second because the font-family name in the CSS did not match the name used in the rule. The browser gives no visible error for either. (WordPress.org support thread, around early 2024)
  • Google Fonts still load after “turning them off”. A user of a disable-Google-Fonts plugin still saw Roboto requested from Google; the source was a separate post-grid plugin with its own Google Fonts setting, plus cached pages. Check every theme and plugin font option, then clear all caches. (WordPress.org support thread)
  • The first font upload fails. During the 6.5 beta, installing a font failed the first time because the uploads/fonts folder did not exist yet; the bug was fixed before release, but a failed upload today is still worth checking against folder permissions under wp-content/uploads. (Gutenberg issue #59023)
  • The “disable Font Library” snippet stopped working in 7.0. A reader reported in May 2026 that the published snippet no longer hid fonts management, because 7.0 added the Appearance > Fonts screen; removing that submenu hides it but leaves the URL reachable. Our version above handles both. (comment on the Developer Blog snippet)

Frequently asked questions

How do I change the font of my whole WordPress site?

In a block theme, go to Appearance > Editor > Styles > Typography and pick fonts for text and headings. In a classic theme, use the theme’s typography options if it has them, or add a font-family rule on body in Appearance > Customize > Additional CSS.

Where are WordPress fonts stored?

Theme fonts live in the theme folder, usually assets/fonts/. Fonts added through the Font Library are stored in wp-content/uploads/fonts/ unless a plugin changes that with the font_dir filter.

Can I use the font tag in a WordPress post?

You can type it in a Custom HTML block, but you should not. It is obsolete HTML, it mixes styling into content, and it ignores your theme’s font settings. Select the text’s block and choose a font in the Typography panel instead.

Why does my font look different in the editor and on the site?

Usually the font is loaded on one side only. Theme fonts in theme.json and Font Library fonts load in both places automatically. A font added with wp_enqueue_scripts alone reaches only the front end; enqueue it for the editor too, as in the classic theme example above.

What fonts are web safe in WordPress?

System font stacks such as system-ui, sans-serif need no download at all and look native on every device. Many block themes include a “System Sans-serif” option for exactly this reason. It is the fastest choice when brand type is not a requirement.

Is a bold font a different font file?

With static fonts, yes: each weight is its own file. With a variable font, one file covers the whole weight range. Our short explainer on a bold font style used in WordPress covers the styling side.

Related reading

Fonts and menus are usually the first two things people inspect in a theme header. For the other half, see our breakdown of the HTML for a navigation menu in WordPress, which covers the classes and ARIA attributes the Navigation block prints.

Part of the Wbcom Designs family

The all-in-one WordPress community stack

Also ours: wbcomdesigns.comvapvarun.combrndle.com