HTML5 details element for accordion -
is details element semantically appropriate markup accordion?
example:
<div class="accordion"> <details open> <summary>section 1</summary> </details> <details> <summary>section 2</summary> </details> <details> <summary>section 3</summary> </details> </div> i ask question because spec isn't clear usage. states details element disclosure widget. don't want use element it's not meant be.
edit
would better suited semantically?
<article role="tablist"> <header role="tab" aria-expanded>section 1</header> <div role="tabpanel"> </div> <header role="tab">section 2</header> <div role="tabpanel"> </div> <header role="tab">section 3</header> <div role="tabpanel"> </div> </article> thanks!
yes, <details><summary> elements entirely appropriate (and semantic option) you're describing:
from http://www.w3.org/html/wg/drafts/html/master/interactive-elements.html#the-details-element:
the details element represents disclosure widget user can obtain additional information or controls. [emphasis mine]
and http://html5doctor.com/the-details-and-summary-elements/:
essentially, can use create accordion-like widget user can toggle open , closed. inside , can put sort of content want.
perfect usage. example, company has contact page many contact options setup accordion so:
<details> <summary>mailing address</summary> <p><strong>u.s. correspondence:</strong> 123 main st., washington, dc 00000-0000</p> <p><strong>international correspondence:</strong> p.o.box 1111, washington, dc 00000-1111</p> </details> <details> <summary>phone numbers</summary> <p><strong>u.s.:</strong> 800-555-5555</p> <p><strong>int'l:</strong> +1-800-555-5556</p> </details> a note on styling: semantics shouldn't thrown overboard address browser-specific styling issues. css reset may in order, there's no semantic reason not use these helpful , appropriate elements accordion.
**do note: chrome browser supports toggling functionality believe spec intended these elements. javascript fallback useful here.
**edit 3/2017 - see http://caniuse.com/#feat=details support tables. feature supported ie , edge.
Comments
Post a Comment