Skip to main content

HTML Guide

CSS: “align-items”: “auto” is not a “align-items” value.

The issue you’re encountering indicates that the CSS property align-items is being set to a value of auto, which is not a valid value for this property according to the CSS specification. The align-items property is used in flexbox and grid layouts to define how items are aligned along the cross axis.

Fixing the Issue:

  • Understand Valid Values: The valid values for the align-items property include:

    /* Basic keywords */
    align-items: normal;
    align-items: stretch;
    
    /* Positional alignment */
    /* align-items does not take left and right values */
    align-items: center;
    align-items: start;
    align-items: end;
    align-items: flex-start;
    align-items: flex-end;
    align-items: self-start;
    align-items: self-end;
    align-items: anchor-center;
    
    /* Baseline alignment */
    align-items: baseline;
    align-items: first baseline;
    align-items: last baseline; /* Overflow alignment (for positional alignment only) */
    align-items: safe center;
    align-items: unsafe center;
    
    /* Global values */
    align-items: inherit;
    align-items: initial;
    align-items: revert;
    align-items: revert-layer;
    align-items: unset;
    
  • Choose a Correct Value: Based on the desired alignment, choose one of the valid values. For instance:

    • Use flex-start to align items to the start of the container.
    • Use center to align items in the center.
    • Use stretch to stretch items to fill the container.
  • Example Correction: If your original CSS was:

     .container {
       display: flex;
       align-items: auto; /* This is invalid */
     }

    You could change it to:

     .container {
       display: flex;
       align-items: center; /* This is valid */
     }

Conclusion:

Replace the invalid auto value with a valid option that suits the design you aim for, making sure to test the layout after applying changes to confirm that the items align as intended.

Learn more:

Related W3C validator issues