====== 2.1.2. Accordions ====== ===== Purpose ===== Accordions are dynamic modules used to display multiple blocks of content on a single page without scrolling. Each block can be opened or closed (fold/unfold) through the heading or title above. ===== Basic HTML code ===== An example of the basic HTML code for an accordion with panels concealed by default is shown below. This code may be modified according to the context, notably with respect to the different heading levels.

Heading of the first panel

Content of the first panel

Heading of the second panel

Content of the second panel

Heading of the third panel

Content of the third panel

Without JavaScript, all panels are displayed. **Note** Even though it is not so recommended, it is possible, without JavaScript, to keep the links inside the headings. In this case, they are links that point to the corresponding anchors:

Heading of the first panel

Content of the first panel

===== Behaviour with JavaScript ===== The scripts are then added to the basic HTML code to handle the following points: - The panel headings include links that make it possible to fold or unfold the panels. - The panels are hidden by default using the property ''display: none'' in the CSS. - By using the mouse or the keyboard to execute a link-heading, you can display or hide the corresponding panel (''display: none'' to hide it and ''display: block'' to display it). - The ''aria-expanded="false"'' attribute is applied by default on the link-heading. The value of this attribute then changes dynamically to ''true'' when the corresponding content is displayed and ''false'' otherwise. - The ''aria-controls'' attribute is applied to the link-heading. The value of this attribute is retrieved from the ID attribute of the corresponding panel. The resulting code with JavaScript is as follows:

First panel content (hidden)

Second panel heading

Second panel content (displayed)

Third panel content (hidden)

===== Demonstration ===== * [[http://accede.info/demos/en/demo-accordeon-accessible-en/|Online demo of an accordian]].