Skip to main content
HTML Validation

Bad value “%” for attribute “width” or “height” on element “object”: Expected a digit but saw “%” instead.

About This HTML Issue

Attribute values for width and height on the object element must be a valid integer (pixels), not a percentage.

In HTML5, the width and height attributes for the <object> element must be specified in pixels as an integer value, such as height="500". Using percentage values like height="100%" is not allowed in the attribute according to the HTML living standard and will trigger a validation error. To set a percentage height, use the CSS width and height properties instead.

Correct usage (pixels via attribute):

<object data="example.pdf" type="application/pdf" width="600" height="400"></object>

Correct usage (percentage via CSS):

<object data="example.pdf" type="application/pdf" style="width: 100%; height: 100%;"></object>

Example of a full valid HTML document using CSS for 100% height:

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Object Height Example</title>
  <style>
    html, body {
      height: 100%;
      margin: 0;
    }
    object {
      height: 100%;
      width: 100%;
      display: block;
    }
  </style>
</head>
<body>
  <object data="example.pdf" type="application/pdf"></object>
</body>
</html>

Last reviewed: May 16, 2025

Was this guide helpful?

Find issues like this automatically

Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.

Ready to validate your sites?
Start your free trial today.