WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: Expander links

for

From: John Foliot
Date: Apr 15, 2010 6:30PM


Jared Smith wrote:
>
> Yes. Some of the time. There really isn't a 'hidden' attribute.

...in HTML 4/XHTML 1, however HTML5 does introduce such an attribute:
http://dev.w3.org/html5/spec/Overview.html#the-hidden-attribute

...quoted in its entirety below.

IMPORTANT NOTE: HTML5 is in a constant state of flux, and this may or may
not be the final spec, and may or may not be currently implemented in all
browsers. But thought y'all might like to know...

JF

******************

"All HTML elements may have the hidden content attribute set. The hidden
attribute is a boolean attribute. When specified on an element, it
indicates that the element is not yet, or is no longer, relevant. User
agents should not render elements that have the hidden attribute
specified.

In the following skeletal example, the attribute is used to hide the Web
game's main screen until the user logs in:
<h1>The Example Game</h1>
<section id="login">
<h2>Login</h2>
<form>
...
<!-- calls login() once the user's credentials have been checked -->
</form>
<script>
function login() {
// switch screens
document.getElementById('login').hidden = true;
document.getElementById('game').hidden = false;
}
</script>
</section>
<section id="game" hidden>
...
</section>

The hidden attribute must not be used to hide content that could
legitimately be shown in another presentation. For example, it is
incorrect to use hidden to hide panels in a tabbed dialog, because the
tabbed interface is merely a kind of overflow presentation - one could
equally well just show all the form controls in one big page with a
scrollbar. It is similarly incorrect to use this attribute to hide content
just from one presentation - if something is marked hidden, it is hidden
from all presentations, including, for instance, screen readers.

Elements that are not hidden should not link to or refer to elements that
are hidden.

For example, it would be incorrect to use the href attribute to link to a
section marked with the hidden attribute. If the content is not applicable
or relevant, then there is no reason to link to it.

It would similarly be incorrect to use the ARIA aria-describedby attribute
to refer to descriptions that are themselves hidden. Hiding a section
means that it is not applicable or relevant to anyone at the current time,
so clearly it cannot be a valid description of content the user can
interact with.

Elements in a section hidden by the hidden attribute are still active,
e.g. scripts and form controls in such sections still execute and submit
respectively. Only their presentation to the user changes.

The hidden IDL attribute must reflect the content attribute of the same
name."