Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP C C++ C# AWS W3.CSS HOW TO BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST TOOLS

W3.CSS Fonts

W3.CSS Fonts

W3.CSS uses fonts that are easy to read on screens.

You can use the default fonts, built-in font classes, or your own fonts.

Default Fonts

Verdana is the default font used in W3.CSS. It has a good letter spacing and is easy to read.

Segoe UI is the default font for headings. It has a more narrow letter spacing, which allows for a few more letters in the headings.

This is a Heading

This is normal paragraph text.

Example

<h2>This is a Heading</h2>
<p>This is normal paragraph text.</p>
Try it Yourself »

Font Classes

W3.CSS provides four font classes:

Class Font Style
w3-serif Serif
w3-sans-serif Sans serif
w3-monospace Monospace
w3-cursive Cursive

Serif

The w3-serif class uses a serif font:

The quick brown fox jumps over the lazy dog.

Example

<p class="w3-serif">The quick brown fox jumps over the lazy dog.</p>
Try it Yourself »

Sans Serif

The w3-sans-serif class uses a sans serif font.

The quick brown fox jumps over the lazy dog.

Example

<p class="w3-sans-serif">The quick brown fox jumps over the lazy dog.</p>
Try it Yourself »

Monospace

In a monospace font, every character has the same width.

Monospace fonts are often used for computer code.

const message = "Hello World";

Example

<p class="w3-monospace">const message = "Hello World";</p>
Try it Yourself »

Cursive

The w3-cursive class uses a cursive font.

The quick brown fox jumps over the lazy dog.

Example

<p class="w3-cursive">The quick brown fox jumps over the lazy dog.</p>
Try it Yourself »

Combine Font Classes with Text Sizes

Font classes can be combined with other W3.CSS classes.

Monospace Header

Serif Large

Sans serif text

Cursive red text

Example

<h1 class="w3-monospace">Monospace Header</h1>
<p class="w3-serif w3-xxlarge">Serif Large</p>
<p class="w3-sans-serif w3-large">Sans serif text</p>
<p class="w3-cursive w3-xlarge w3-text-red">Cursive red text</p>
Try it Yourself »

Use Your Own Font

You are not limited to the built-in W3.CSS fonts.

Use CSS font-family to choose your own font.

Example

body {
  font-family: Arial, Helvetica, sans-serif;
}
Try it Yourself »

In the example above:

  • Arial is the preferred font
  • Helvetica and sans-serif are fallback fonts

Always provide fallback fonts in case the preferred font is not available.


Change the Font for the Whole Page

You can change the fonts for both normal text and headings.

Example

body, h1, h2, h3, h4, h5, h6 {
  font-family: Arial, Helvetica, sans-serif;
}
Try it Yourself »

What You Have Learned

  • Verdana is the default font for normal W3.CSS text
  • Segoe UI is the default font for W3.CSS headings
  • w3-serif displays serif text
  • w3-sans-serif displays sans serif text
  • w3-monospace displays fixed-width text
  • w3-cursive displays cursive text
  • Font classes can be combined with other W3.CSS classes
  • You can use CSS to choose your own fonts


More Examples

Explore more fonts and font combinations.


Web Safe Sans Serif Fonts

Font FamilySafe Fallback
ArialHelvetica, sans-serif
HelveticaArial, sans-serif
VerdanaGeneva, sans-serif
GenevaVerdana, sans-serif
TahomaArial, sans-serif
Trebuchet MSArial, sans-serif

Web Safe Serif Fonts

Font FamilySafe Fallback
Times New RomanTimes, serif
Georgiaserif

Font Arial

body, h1, h2, h3, h4, h5, h6 {
  font-family: Arial, Helvetica, sans-serif;
}
Try it Yourself »

Arial is considered the safest sans-serif font on the web. It is installed on all Windows machines and all Mac machines.

Helvetica is the preferred fallback because the two fonts are almost identical. Helvetica runs on all Mac machines but on fewer Windows machines.

Using Arial with Helvetica fallback, or Helvetica with Arial fallback, covers both worlds.


Font Helvetica

<style>
body, h1, h2, h3, h4, h5, h6 {
  font-family: Helvetica, Arial, sans-serif;
}
</style>
Try It Yourself »

Font Verdana

body, h1, h2, h3, h4, h5, h6 {
  font-family: Verdana, Geneva, sans-serif;
}
Try It Yourself »

Verdana is considered to be a web safe sans-serif font. It runs on all Windows machines, and all Mac Machines.

Geneva is Verdanas preferred fallback, because the two fonts are quite similar, and Geneva runs on all Mac machines (99.6%).


Font Tahoma

body, h1, h2, h3, h4, h5, h6 {
  font-family: Tahoma, "Trebuchet MS", sans-serif;
}
Try It Yourself »

Tahoma was the standard font in Windows 95. It works on all Windows machines, and most Mac machines.


Font Trebuchet MS

body, h1, h2, h3, h4, h5, h6 {
  font-family: "Trebuchet MS", Tahoma, sans-serif;
}
Try It Yourself »

Trebuchet MS has been released with all Windows operating systems since Microsoft Windows 2000. It is also included on Macs machines, iOS and Chrome OS.

Font Segoe UI

body, h1, h2, h3, h4, h5, h6 {
  font-family: "Segoe UI", Arial, sans-serif
}
Try It Yourself »

Segoe UI is the default font in Windows (from Windows 10). It is also the default heading font in W3Schools and in W3.CSS.


Font Times New Roman

body, h1, h2, h3, h4, h5, h6 {
  font-family: "Times New Roman", Times, serif;
}
Try It Yourself »

Times New Roman is considered the most web safe serif font. It works on all Windows machines and all Mac machines.

Some older operating systems might have an alternative version called Times, so it is smart to use Times as a fallback as well as serif.


Font Georgia

body, h1, h2, h3, h4, h5, h6 {
  font-family: Georgia, serif;
}
Try it Yourself »

Georgia is also considered very safe. It is a little larger than Times New Roman, but works well on Windows and Mac machines.

To be on the safe side, use serif as fallback.


Monospace Fonts

In a monospace font, all letters occupy the same width.

Monospaced fonts are often used to display computer code.

Font FamilySafe Fallback
Courier Newmonospace
Lucida ConsoleMonaco, monospace
MonacoLucida Console, monospace

Note

There are no 100% web safe fonts, but you can always use w3-monospace.


Font Courier New

body, h1, h2, h3, h4, h5, h6 {
  font-family: "Courier New", monospace;
}
Try it Yourself »

Courier New is considered the most web safe monospace font. It is installed on all Windows and Mac machines.


Font Lucida or Monaco

body, h1, h2, h3, h4, h5, h6 {
  font-family: "Lucida Console", Monaco, monospace;
}
Try It Yourself »

Lucida Console does not run on Mac. Monaco does not run on Windows.

One solution is to use Monaco as fallback for Lucida Console.


Font w3-monospace

<div class="w3-monospace">
Try It Yourself »

Handwriting Fonts

There are no web safe handwriting fonts, but you can safely use w3-cursive.

Font w3-cursive

<div class="w3-cursive">
Try It Yourself »

Google Fonts

You can also use external fonts with W3.CSS.

Google Fonts provides many fonts that can be added to your web pages.

Example

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto">

<style>
body {
  font-family: Roboto, sans-serif;
}
</style>
Try it Yourself »

More Google Font Examples »


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.

-->