W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2014

Re: [whatwg] hidden attribute useless with display: flex?

From: Ian Hickson <ian@hixie.ch>
Date: Thu, 1 May 2014 17:01:35 +0000 (UTC)
To: David Bruant <bruant.d@gmail.com>
Message-ID: <alpine.DEB.2.00.1405011657010.30476@ps20323.dreamhostps.com>
Cc: whatwg <whatwg@whatwg.org>
On Thu, 1 May 2014, David Bruant wrote:
> Le 30/04/2014 23:32, Ian Hickson a écrit :
> > > > What I'm trying to do is just that an element have display:flex 
> > > > and to hide it with the hidden attribute when I don't need the 
> > > > element to be shown. I guess my only option is changing 
> > > > style.display?
> >
> > Just add "[hidden] { display: none }" to your style sheet.
>
> Hmm... interesting. And that works because my stylesheet is the author 
> stylesheet which takes precedence over the UA stylesheet.
> 
> Is there a scenario where CSS specificity leads to this rule being 
> ignored?

Yeah, as usual specificity can rock the boat. :-)

   div.ui { display: flex; }

...would override it (since 0,0,1,1 > 0,0,1,0). But if that's an issue, 
you can move this to the !important level:

   [hidden] { display: none ! important; }


> If the answer is no, I'm sold. It's not any worse than *{box-sizing: 
> border-box} which I do all the time.

Yeah, it's exactly like that. Or * { font: inherit; }, which I do all the 
time, but which you then have to "fix" for headings and <strong> and so on.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Thursday, 1 May 2014 18:26:51 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:20 UTC