Start Debugging
2012-03-02 Updated 2023-11-05 css

CSS How to use Custom Fonts

Learn how to use custom fonts in CSS3 with the @font-face rule, including syntax examples and a demo.

CSS3 allows the use of custom fonts through the @font-face rule. They are really easy to add and the syntax looks like this:

@font-face {
    font-family: someFont;
    src: url('path/font.ttf');
}

This declares a font for use within your web page. An example would be:

@font-face {
    font-family: CODEBold;
    src: url('../fonts/CODEBold.otf');
}

Now to apply the custom font to your text you can use the font-family property:

<h1 style="font-family: CODEBold">Start Debugging</h1>

A great source for custom fonts would be dafont.com
Check out a demo here: Custom Fonts Demo

< Back