Computer >> Computer tutorials >  >> Programming >> CSS

How to create responsive typography with CSS?


To create responsive typography with CSS, the code is as follows −

Example

<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<head>
<style>
   h1 {
      font-size: 10vw;
   }
   p {
      font-size: 5vw;
   }
</style>
</head>
<body>
<h1>Responsive Text Example</h1>
<p>
Lorem ipsum dolor sit amet consectetur, adipisicing elit. Earum, rerum.
</p>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Excepturi, necessitatibus officiis hic est in nobis!
</p>
</body>
</html>

Output

The following output will be produced by the above code −

How to create responsive typography with CSS?

On resizing the screen −

How to create responsive typography with CSS?