Set Font Size with em using CSS

To set font size with pixels, use the em unit, with the font-size property.

1em = 16px


You can try to run the following code to set font size with em

Live Demo

<!DOCTYPE html>
         h1 {
            /* 30px/16 = 1.875em */
            font-size: 1.875em;
      <h1>This is demo heading</h1>
      <p>This is demo text.</p>