Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hidden] attribute ignored on certain elements #4872

Closed
luchaos opened this issue Jul 2, 2021 · 2 comments · Fixed by #4873
Closed

[hidden] attribute ignored on certain elements #4872

luchaos opened this issue Jul 2, 2021 · 2 comments · Fixed by #4873

Comments

@luchaos
Copy link

luchaos commented Jul 2, 2021

What version of Tailwind CSS are you using?

2.1.2

What build tool (or framework if it abstracts the build tool) are you using?

postcss: ^8.3.5, webpack: ^5.40.0, laravel-mix: ^6.0.24, @tailwindcss/jit: ^0.1.18

What version of Node.js are you using?

v14.17.1

What browser are you using?

Chrome

What operating system are you using?

macOS

Reproduction repository

https://github.com/luchaos/tailwind-hidden-attribute

Screenshot 2021-07-02 at 14 56 36

Describe your issue

From Tailwind CSS' code:

/**
 * Make replaced elements `display: block` by default as that's
 * the behavior you want almost all of the time. Inspired by
 * CSS Remedy, with `svg` added as well.
 *
 * https://github.com/mozdevs/cssremedy/issues/14
 */
img,
svg,
video,
canvas,
audio,
iframe,
embed,
object {
  display: block;
  vertical-align: middle;
}

This causes <iframe hidden> to be displayed (among the other elements above).

The project linked in the comment, which inspired the reset, has/had a similar issue with handling of the hidden attribute. See:

It's possible to fix this simply by adding [hidden] { display: none }, yet,
this should probably be handled in Tailwind CSS itself, too? I was not able to find a reference to that particular handling of the hidden attribute in issues/code.


The problem occurred in a project I'm working on when adding a third party live chat widget. It renders an iframe with a hidden attribute initially but stayed visible at all times. In turn, the widget's event listeners weren't initialized and the close/toggle button did not work either. But that's a completely different issue.

@luchaos luchaos changed the title [hidden] attribute is ignored on certain elements [hidden] attribute ignored on certain elements Jul 2, 2021
@adamwathan
Copy link
Member

Good catch, fixing in #4873.

@rubencarv
Copy link

rubencarv commented Jul 21, 2022

@adamwathan This seems to be an issue again in version 3.1.6.
The elements are displaying again despite setting the hidden attribute. Eg.
<audio hidden ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants