Paul Clavier Paul Clavier - 1 year ago 123
HTML Question

Scaling font size with screen size?

I'm developing a web app with AngularJS 1.x and Angular Material. I'm trying to create a landing page with a large title at


Here's what it looks like:

App on large screen

As you can see, the title fills the page nicely and fits in one line.

However, this is on a 1680x1050 monitor. If I move the browser window to my smaller 1366x768 monitor, I get this instead:

App on smaller screen

As you can see, the font stays the same physical size and overruns to the next line, and also is no longer centred.

How can I ensure a consistent look where font scales depending on screen size?

Here's my code:

<title>FOOBY DOOBY</title>

<link rel="stylesheet" href="">
<link rel="stylesheet" href=",400,500,700,400italic">

<link rel="stylesheet" href="styles.css" />

<!-- Angular Material requires Angular.js Libraries -->
<script src=""></script>
<script src=""></script>
<script src=""></script>
<script src=""></script>

<!-- Angular Material Library -->
<script src=""></script>

<script src="app.js"></script>
<body ng-app="homePage">
<div layout="column">
<div layout layout-align="center">
<h1 class="md-display-4">FOOBAR IS THE TITLE HERE</h1>
<!-- Description here -->

Answer Source

You can use viewport units, for example:

h1 {
    font-size: 10vw;
<h1>Foobar is the title here</h1>

Browser support reference

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download