Skip to main content

HTML Guide

CSS: “font-size”: X is not a “font-size” value.

A value specified for the font-size property in your CSS is not a valid CSS length or keyword.

The font-size property accepts values such as keywords (small, large), absolute and relative lengths (px, em, rem, pt), or percentages. Invalid values, like font-size: X;, are not recognized and trigger a validation error.

Common valid values for font-size:

  • Keywords: small, medium, large, etc.
  • Length units: 12px, 1em, 0.9rem, 10pt
  • Percentages: 120%

Example with a valid value:

<p style="font-size: 16px;">This text uses a valid font size.</p>

Example using a keyword:

<p style="font-size: large;">This text uses a valid keyword.</p>

Full HTML example (valid):

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Valid Font Size Example</title>
  </head>
  <body>
    <p style="font-size: 1.2em;">Valid font size using em unit.</p>
  </body>
</html>

Check that all font-size values use proper CSS units or accepted keywords to resolve the validation warning.

Learn more:

Related W3C validator issues