Remove the hidden attribute. Its functionality is already fulfilled by the use of CSS and ARIA attributes. It is redundant, and its inclusion in HTML5 introduces inconsistent and non-complementary directions from the W3C. RationaleMy change proposal for Issue 95 is about removing the hidden attribute[1]: The HTML5 specification states the following about this attribute[2]:
The hidden attribute section provides one example: a game screen is hidden until a person has logged in. Rationales for Keeping the AttributeThe HTML5 editor, Ian Hickson, wrote the following rationale as reason for rejecting this change in the associated bug[3]
A counter-proposal has been provided to keep the attribute. The rational given is[4]:
In addition, the Accessibility TF discussed the change proposal[5], and among the benefits discussed were the following:
The Accessibility Task Force also provided a general statement regarding this element and others:
ResponseI took a best guess effort at summarizing the rationales for keeping the hidden attribute.
I say "best guess" at summarizing, because the discussion points from the Accessibility TF seem to indicate that some members of the discussion don't think the hidden attribute is particularly useful. I do agree with the counter proposals that the hidden attribute is easy to use. From the example in the specification—set the value to true, to hide the element' contents, false, to display the contents—you can't get a simpler attribute. I also agree that HTML4 did not have an equivalent functionality built into the specification. However, I do not agree with the other statements given. The Existing Behavior with JavaScript and CSS, Media, and SimplicityThe HTML5 specifications defines the rendering for the hidden attribute to be equivalent to setting the element's display property to "none"[6]. You'd get the same effect with the following code:
Or the following code:
As you would setting the hidden attribute:
You could even absolutely, positively, completely ensure the accessibility of the effect, using the following: [aria-hidden="true"] { display: none; } ... document.getElementById("elem").setAttribute("aria-hidden","true"); If any user agents do render content when the element's display property is set to "none", it's the fault of the user agent, not the CSS or aria-hidden attribute. If user agents have problems with display being set to "none", they will continue to have problems with the hidden attribute because the two are equivalent. As for simplicity, both approaches are again, exactly equivalent. The Semantics of IrrelevanceThe hidden attribute was once named the irrelevant attribute, supposedly because the attribute is used to mark the contents of whatever element it is attached as "irrelevant". The attribute was renamed because, a) the irrelevant term was confusing, and b) techs misspell words like "irrelevant". Is the content truly irrelevant, though? Consider the definition for the attribute:
An irrelevant element is not one that is active, receiving events, participating in the web page, or form submission. The only truly irrelevant page component is one that doesn't exist. If people want a truly irrelevant page section, they should use the DOM to create and remove the element, as needed. There is nothing about the behavior associated with removing an element from user agent rendering that is made more meaningful using a single-purposed HTML attribute, rather than using a simple combination of CSS property and ARIA attribute. Both have to do with the presentation of the element. Presentation with the hidden attribute isn't an incidental purpose, it is the primary purpose of the attribute. Rather than separate presentation and structure, it firmly welds the two. AccessibilityThe hidden attribute is no more accessible than setting the element's CSS display property to "none", because the two are equivalent. However, the hidden attribute can be detrimental to accessibility because there's nothing in the HTML5 specification that describes the precedence of settings. The ARIA documentation states that ARIA settings, such as aria-hidden, take precedence over settings such as display="none". Does the aria-hidden attribute have precedence, then, over the hidden attribute? How about when hidden is set to true, but a CSS stylesheet sets the display property of the element to "block"? Introducing hidden introduces a redundancy, yet the documentation for hidden does not take such redundancy into account when defining the attribute. CostsThe costs for an attribute such as hidden, are not as high as a more complex object, such as the details element. However, there are costs. Lint tools and validators now have to ensure conforming use of the attribute, HTML editing tools and WYSIWYG applications have to incorporate the new functionality, libraries have to be modified, books updated, design themes modified, and so on. Web developers and designers have to spend time trying to figure out when to use CSS, and when to use the hidden attribute. I can imagine the many discussions about 'irrelevant" content, and what does "irrelevant" mean in one context or another. It is an esoteric concept, and as such adds unnecessary complexity. If the attribute provided something useful, it might be worth the costs. However, the hidden attribute provides absolutely nothing that we don't already have. Details
ImpactPositive EffectsThis removes an inconsistent approach for hidden content that can cause confusion to developers about which direction to follow when hiding page content. This also removes a redundant attribute, helping to simplify the HTML5 specification. For browser developers and other user agents, this change reduces the need to support an HTML5 attribute, in addition to CSS and ARIA states that perform the exact same behavior. HTML editors will have one less new HTML5 attribute to worry about implementing. Authors, developers, and designers will have a clear direction to follow for element display and visibility Negative EffectsIt will take Editor time to implement the change. However, this is balanced with the hundreds, perhaps thousands of hours necessary to implement this attribute in user agents. And since this attribute has not been implemented yet, there is no other negative cost to the change. |