How to use CSS to change the font family in HTML

How to use CSS to change the font family in HTML

ยท

1 min read

To change the font family in the HTML with CSS added the following content to your code,

.font2{
  font-family: "Comic Sans MS";
}

The same goes for different fonts,

<div class="container">
  <p class="font1">Hello world</p>
  <p class="font2">Hello World</p>
  <p class="font3">Hello World</p>
</div>

and to change the font family of all these fonts,

.font1{
  font-family: "Arial", sans-serif;
}

.font2{
  font-family: "Comic Sans MS";
}

.font3{
  font-family: "PT Sans", sans-serif;
}

Live demo,

ย