<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>152883</bug_id>
          
          <creation_ts>2016-01-08 01:47:43 -0800</creation_ts>
          <short_desc>User Agent style sheet should include !important directive when defining display:none on [hidden] attribute selector</short_desc>
          <delta_ts>2023-06-27 11:12:40 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>CSS</component>
          <version>Safari 9</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar, WPTImpact</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="James Craig">jcraig</reporter>
          <assigned_to name="James Craig">jcraig</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>ap</cc>
    
    <cc>dino</cc>
    
    <cc>eoconnor</cc>
    
    <cc>ian</cc>
    
    <cc>jcraig</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>tabatkins</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zalan</cc>
    
    <cc>zcorpan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1153783</commentid>
    <comment_count>0</comment_count>
    <who name="James Craig">jcraig</who>
    <bug_when>2016-01-08 01:47:43 -0800</bug_when>
    <thetext>User Agent style sheet should include !important directive when defining display:none on [hidden] attribute selector...

WebKit uses the WHATWG spec recommendation for display:none on html:*[hidden]

&gt; [hidden], area, base, basefont, datalist, head, link, menu[type=context i], meta,
&gt; noembed, noframes, param, rp, script, source, style, template, track, title {
&gt;   display: none;
&gt; }

https://html.spec.whatwg.org/multipage/rendering.html#hiddenCSS

...but as specified, the behavior of @hidden is too easy to accidentally override.

&lt;div hidden&gt; example &lt;/div&gt;

Even a simple element selector negates the usefulness of the @hidden API and causes the element to be displayed.
div { display: block; }

And the API no longer works on any element matching an author defined display rule.
el.hidden = true; // Does nothing.

I believe the solution is to change the user agent CSS (and the ultimately the HTML specs) to include this rule block:

[hidden] {
  display: none !important;
}

This way the @hidden API leverages a higher specificity than all common CSS selectors.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1277745</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2017-02-16 10:43:33 -0800</bug_when>
    <thetext>&lt;rdar://problem/30559389&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1745373</commentid>
    <comment_count>2</comment_count>
    <who name="Simon Pieters (:zcorpan)">zcorpan</who>
    <bug_when>2021-03-30 15:44:40 -0700</bug_when>
    <thetext>Not using !important for [hidden] is intentional, as it allows for more author control of how to hide it. Also there are other rules (embed, table elements) with [hidden] in the UA stylesheet (in the spec) that could complicate things if you add !important.

https://html.spec.whatwg.org/multipage/rendering.html#hidden-elements
https://html.spec.whatwg.org/multipage/rendering.html#tables-2

&gt; ...but as specified, the behavior of @hidden is too easy to accidentally override.

How often do web developers run into this? Are there other solutions that address the issue without taking away control, e.g. mapping [hidden] to  content-visibility: hidden; instead?

It would be good to discuss this in a whatwg/html issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1898029</commentid>
    <comment_count>3</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-09-12 15:05:13 -0700</bug_when>
    <thetext>Is it something clarified with WHATWG/html now or is it something need to be fixed in html.css file for all [hidden] attributes? Appreciate if someone can clarify. Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1898285</commentid>
    <comment_count>4</comment_count>
    <who name="Simon Pieters (:zcorpan)">zcorpan</who>
    <bug_when>2022-09-13 10:44:14 -0700</bug_when>
    <thetext>The spec now has:


[hidden]:not([hidden=until-found i]) {
  display: none;
}

[hidden=until-found i]:not(embed) {
  content-visibility: hidden;
}

embed[hidden] { display: inline; height: 0; width: 0; } 

colgroup, colgroup[hidden] { display: table-column-group; }
col, col[hidden] { display: table-column; }
thead, thead[hidden] { display: table-header-group; }
tbody, tbody[hidden] { display: table-row-group; }
tfoot, tfoot[hidden] { display: table-footer-group; }
tr, tr[hidden] { display: table-row; }
td, th { display: table-cell; }

colgroup[hidden], col[hidden], thead[hidden], tbody[hidden],
tfoot[hidden], tr[hidden] {
  visibility: collapse;
}


&quot;until-found&quot; is https://bugs.webkit.org/show_bug.cgi?id=238266</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>