Favorites

CSS <generic-family> Data Type

<generic-family>
CSS Data TypeThis data type is supported by all modern browsers.
Updated 21st November 2026

The <generic-family> data type is a general font category, such as serif, sans-serif, monospace or system-ui, used as the last fallback in font-family.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

Description

The <generic-family> CSS data type represents a keyword that names a general category of font, such as serif, sans-serif or monospace, rather than a specific font file. It is used in the font-family property and the font shorthand. When the browser sees a generic family, it picks a suitable installed font from that category, which means text is always readable even if none of the named fonts are available.

Because the browser and operating system decide which actual font is used, a generic family is normally placed at the end of a font-family list as the final fallback. For example, font-family: "Open Sans", Arial, sans-serif; tries Open Sans, then Arial, and if neither exists, uses the system's default sans-serif font. Generic family names are keywords, so they must not be put in quotes. Writing "serif" would make the browser look for a font literally named "serif".

The classic generic families are serif, sans-serif, monospace, cursive and fantasy. Newer families give access to the fonts of the user's own interface, such as system-ui and the ui-serif, ui-sans-serif, ui-monospace and ui-rounded keywords, as well as specialised families like math for mathematical notation, emoji for emoji characters and fangsong for a style of Chinese typeface. Support for the newer keywords varies; for example, the ui-* families are mainly supported in Safari, while system-ui works in all modern browsers.

Examples:

body {
  font-family: "Open Sans", Arial, sans-serif;
}

code, pre {
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

.app-ui {
  font-family: system-ui, sans-serif;
}

blockquote {
  font-family: Georgia, "Times New Roman", serif;
}

Ending every font stack with a <generic-family> keyword is a simple habit that keeps your typography predictable on every device.

Interactive Demo

The quick brown fox jumps over 123

Demo Code
HTML Code
<p class="demo-element">The quick brown fox jumps over 123</p>
CSS Code
.demo-element {
	width: 260px;
	margin: 0;
	padding: 10px 12px;
	border: 2px solid #4361ee;
	border-radius: 6px;
	background: #e7ecff;
	color: #1b1f3b;
	font-size: 16px;
	font-size: 20px;
	font-family: serif;
}

Syntax

<generic-family> = serif | sans-serif | monospace | cursive | fantasy | system-ui | ui-serif | ui-sans-serif | ui-monospace | ui-rounded | math | emoji | fangsong

Values

  • serifFonts with small finishing strokes (serifs) at the ends of characters, such as Times New Roman or Georgia.
  • sans-serifFonts without serifs, with plain stroke endings, such as Arial or Helvetica.
  • monospaceFonts in which every character has the same width, such as Courier New or Consolas. Commonly used for code.
  • cursiveFonts that resemble handwriting, with joined or partially joined strokes.
  • fantasyDecorative fonts with playful or ornamental shapes.
  • system-uiThe default user interface font of the operating system.
  • ui-serifThe default serif font of the user interface.
  • ui-sans-serifThe default sans-serif font of the user interface.
  • ui-monospaceThe default monospace font of the user interface.
  • ui-roundedThe default user interface font with rounded features.
  • mathFonts designed for mathematical expressions, with support for superscripts, subscripts and special symbols.
  • emojiFonts designed for displaying emoji characters.
  • fangsongA style of Chinese characters between serif-style Song and cursive-style Kai forms, often used in government documents.

Example

<div class="wrap">
<h1>CSS &lt;generic-family&gt; examples</h1>
<div class="sample serif"><span class="name">serif</span><span class="text">The quick brown fox</span></div>
<div class="sample sans-serif"><span class="name">sans-serif</span><span class="text">The quick brown fox</span></div>
<div class="sample monospace"><span class="name">monospace</span><span class="text">The quick brown fox</span></div>
<div class="sample cursive"><span class="name">cursive</span><span class="text">The quick brown fox</span></div>
<div class="sample fantasy"><span class="name">fantasy</span><span class="text">The quick brown fox</span></div>
<div class="sample system-ui"><span class="name">system-ui</span><span class="text">The quick brown fox</span></div>
<div class="sample math"><span class="name">math</span><span class="text">x&sup2; + y&sup2; = r&sup2;</span></div>
</div>
/* Demonstrates the  keywords */
* { box-sizing: border-box; }

body {
  margin: 24px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: #ffffff;
  color: #111827;
}

.wrap {
  max-width: 760px;
  margin: 0 auto;
}

h1 {
  font-size: 20px;
  margin: 0 0 16px;
}

.sample {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 10px 14px;
  border-bottom: 1px solid #e5e7eb;
}

.sample .name {
  flex: 0 0 130px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 13px;
  color: #6b7280;
}

.sample .text {
  font-size: 22px;
}

.serif .text { font-family: serif; }
.sans-serif .text { font-family: sans-serif; }
.monospace .text { font-family: monospace; }
.cursive .text { font-family: cursive; }
.fantasy .text { font-family: fantasy; }
.system-ui .text { font-family: system-ui; }
.math .text { font-family: math; }
Open in editor

Browser Support

The following information will show you the current browser support for the CSS generic-family data type. Hover over a browser icon to see the version that first introduced support for this CSS data type.

This data type is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.