Skip to main content

Command Palette

Search for a command to run...

How to use CSS to change the font family in HTML

Published
•1 min read
How to use CSS to change the font family in HTML
D

I am 17 years old and a young passionate and self-taught frontend web developer and have an intention to become a successful developer. I usually write about JavaScript and Web Development and share some tips in the articles.

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,

25 views

More from this blog

D

Dhairya Shah

119 posts