The HTML5 specification already warns developers about this:
Note. . Because this attribute is typically implemented using CSS, it can also be overridden using CSS. For example, a rule that applies "display: block" to all elements overrides the effects of a hidden attribute. Therefore, authors should take care of writing style sheets to ensure that the attribute is still as expected.
- HTML5 Specification - 7.1 hidden attribute
The problem you are facing is that the Bootstrap .btn selector defines display: inline-block , which overrides the hidden display: none attribute.
This means that specificity will be a problem. This is a rare case when !important may be desirable. I would personally follow the following style rule:
[hidden] { display: none !important; }
This ensures that all elements with the hidden attribute are set so that they are not displayed, regardless of their specificity. This is doubly good, as it will make the hidden attribute effective for any browser that supports the [att] selector notation (which is any browser that supports CSS2).
Working demo of JSFiddle .
source share