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

Set Font Size with Pixels using CSS


To set font size with pixels, use the px unit, with the font-size property. You can try to run the following code to set font size with pixels

Example

<!DOCTYPE html>
<html>
   <head>
      <style>
         h1 {
            font-size: 30px;
         }
      </style>
   </head>
   <body>
      <h1>This is demo heading</h1>
      <p>This is demo text.</p>
   </body>
</html>

Output

Set Font Size with Pixels using CSS