Skip to main content

HTML Guide

CSS: “padding-block”: “auto” is not a “padding-block” value.

The CSS property padding-block does not accept auto as a value. The padding-block property is used to set the padding on the block-level start and end sides of an element, and it expects length values (like px, em, %, etc.) or global values like inherit, initial, revert, revert-layer, unset.

Here’s how you can fix this issue by providing valid values for the padding-block property.

Example:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>CSS Padding Block Example</title>
  <style>
    .example {
      /* Incorrect use of 'auto' */
      /* padding-block: auto; */

      /* Correct use of padding-block with length values: */
      padding-block: 20px 10px;

      /* You can also use single value for same padding on both sides: */
      /* padding-block: 15px; */

      /* Or use percentage values: */
      /* padding-block: 2% 1%; */
      /* Or inherit, initial, revert, unset */
      /* padding-block: inherit; */
    }
</style>
</head>
<body>
  <div class="example">
    This is an example demonstrating correct use of padding-block.
  </div>
</body>
</html>

Explanation:

  1. Length values: You can specify the padding using absolute units like px, em, rem, etc. In the example above, padding-block: 20px 10px; applies 20px padding to the block-start and 10px to the block-end.

  2. Single Length Value: Using padding-block: 15px; applies the same padding (15px) to both block-start and block-end.

  3. Percentage values: padding-block: 2% 1%; will apply 2% of the containing block’s size to block-start and 1% to block-end.

  4. Global values: You can also use inherit, initial, revert, revert-layer, or unset to control CSS inheritance and initial values.

Learn more:

Related W3C validator issues