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

On Wed, 30 Apr 2014, David Bruant wrote:
> Le 29/04/2014 23:32, David Bruant a écrit :
> > 
> > // CSS:
> > div {
> >   display: flex;
> > }
> > 
> > // HTML:
> > <div hidden></div>
> > 
> > Per spec, the div should be shown right? I imagine there is no way 
> > back on that?

Right. You want:

   div[hidden] { display: block }

...in your style sheet. It's the equivalent of:

   strong { font: 1em sans-serif; }

...removing the bold, or:

   td.foo { display: none; }

...making all the cells after <td class=foo> end up in the wrong column.


> > Does it mean hidden only works when the default (UA stylesheet) 
> > display value is kept? Does it mean hidden is completely useless when 
> > trying to combine it with display:flex?

No, it just means you have to be careful with your CSS.

Personally I often use this rule:

   [hidden] { display: block; opacity: 0; }

...combined with CSS transitions to animate elements that are being hidden 
or shown. This is one example of why it's important that author CSS be 
able to override the default CSS.


> > 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.


> Constructive proposal:
> * a special value for the hidden attribute that forces the element to be
> hidden regardless of what the CSS or style attribute says for the display
> value.
> Maybe `hidden="force"`?

Hidden how? 'visibility'? 'display'? 'opacity'? Why? What if you later 
want to style it differently?


On Wed, 30 Apr 2014, Anne van Kesteren wrote:
> 
> We could change the specification to use display-box instead. That might 
> work.

Would that break sites that are intentionally replacing the styling for 
hidden="" from 'display:none' to 'opacity:0' ?


On Wed, 30 Apr 2014, Glenn Maynard wrote:
>
> http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-November/037905.html

http://lists.w3.org/Archives/Public/public-whatwg-archive/2012Nov/0143.html

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Wednesday, 30 April 2014 21:33:32 UTC