Skip to main content

HTML Guide

Bad value X” for attribute “height” on element “embed”: Expected a digit but saw “p” instead.

Remove the unit; height on embed expects a non-negative integer (pixels) or a valid CSS length only when set via CSS, not the HTML attribute.

Detailed explanation

The embed element supports the presentational attributes width and height as unsigned integers representing CSS pixels. In HTML, the height attribute must be a number without a unit, for example 650. Supplying 650px violates the attribute’s value syntax and triggers the validator error.

If you want to use units or other CSS lengths (e.g., px, em, %, vh), set them with CSS via the style attribute or a stylesheet using the height property, not the HTML attribute.

HTML examples

Example reproducing the issue

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Embed height invalid</title>
</head>
<body>
  <embed src="file.pdf" type="application/pdf" width="800" height="650px">
</body>
</html>

Corrected example (HTML attribute as integer)

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Embed height fixed</title>
</head>
<body>
  <embed src="file.pdf" type="application/pdf" width="800" height="650">
</body>
</html>

Alternative corrected example (use CSS units)

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Embed height via CSS</title>
  <style>
    .viewer { width: 800px; height: 650px; }
  </style>
</head>
<body>
  <embed class="viewer" src="file.pdf" type="application/pdf">
</body>
</html>

Learn more:

Related W3C validator issues