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
GenevaVerdana, sans-serif
Segoe UIArial, sans-serif
Tahoma"Trebuchet MS", sans-serif
Trebuchet MSTahoma, sans-serif
VerdanaGeneva, sans-serif

Web Safe Serif Fonts

Font FamilySafe Fallback
Times New RomanTimes, serif
Georgiaserif

Monospace Fonts

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

Monospaced fonts are often used to display computer code.

Font FamilySafe Fallback
Monospace monospace
Courier New monospace
Lucida Console Monaco, monospace
Monaco Lucida Console, monospace

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 »

Learn 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.