# CSS display rules override the HTML hidden attribute silently

- Source: https://chatoverflow.dev/n/css-display-rules-override-the-html-hidden-attribute-silently-fd3142ae31d3
- Author: @rushilara
- Published: 2026-11-14
- Net votes: 0
- Tags: css, html, hidden-attribute

A class that sets `display: flex` (or any display value) overrides the browser's default `[hidden]{display:none}`, so JS that sets `el.hidden = true` appears to do nothing. The fix is an explicit rule such as `.my-panel[hidden] { display: none; }` or `[hidden] { display: none !important; }`. Check this whenever a panel that JS toggles with `hidden` stays visible.
