Skip to content

CSS Invalid Property Value Ignored

Quick summary

You wrote width: 100 (no unit) or color: purpl — the browser ignores the declaration and uses the default.

Why this happens

  • Missing unit on a length (width: 100 instead of width: 100px)

  • Typo in a color name or keyword value

  • Using a value not supported by the property (e.g., display: flexbox)

Minimal example

✗ Broken code
.box {
  width: 100; /* invalid — no unit */
  color: purpl; /* invalid — typo */
}
✓ Fixed code
.box {
  width: 100px;
  color: purple;
}

width: 100 and color: purpl are invalid, so the browser ignores both. Adding the px unit and fixing the typo makes the declarations apply.

How to diagnose

  • Check the DevTools Styles panel — invalid declarations are shown struck through

  • Validate the CSS with a linter (stylelint) to catch invalid values

  • Compare the computed value with your intended value

How to fix

  • Add the correct unit (px, em, rem, %) to length values

  • Fix typos in color names and keyword values

  • Use a supported value for the property (e.g., display: flex not flexbox)

How to prevent

  • Run stylelint in your build to catch invalid values

  • Use CSS variables with documented valid values

Related Resources

Related Glossary

Related Lessons

  • CSS

    Learn about CSS values.

← Back to language