Open In App
Related Articles

How to set the font family of text using CSS ?

Improve Article
Save Article
Like Article

The CSS font property is used to set the fonts content of HTML element. The font-family property specifies the font of an element. It can have multiple fonts as a backup system i.e. if the browser doesn’t support one font then the other can be used.


element_selector {
   font-family: fonts-name | initial | inherit;

Property values:

  • fonts-name: The names of the font in quotes separated by commas.
  • initial: It sets the property to its default value.
  • inherit: It inherits the property from the parent element.



<!DOCTYPE html>
        How to set font family
        of text using CSS ?
        body {
            text-align: center;
        h1 {
            color: green;
        .para1 {
            font-family: "Impact", Times, serif;
        .para2 {
            font-family: Arial, Helvetica, sans-serif;
        How to set font family
        of text using CSS ?
    <p class="para1">
        GeeksforGeeks in Impact font
    <p class="para2">
        GeeksforGeeks in Arial font


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 23 Dec, 2020
Like Article
Save Article
Similar Reads
Complete Tutorials