Skip to content

Commit

Permalink
Table Design Pattern and Example: Initial Draft (pull #527)
Browse files Browse the repository at this point in the history
1. Adds initial draft of table design pattern for issue #90.
2. Adds initial draft of table example HTML for issue #242; still needs CSS.
  • Loading branch information
mcking65 authored Nov 18, 2017
1 parent e3be5a4 commit dec93f6
Show file tree
Hide file tree
Showing 3 changed files with 230 additions and 5 deletions.
61 changes: 56 additions & 5 deletions aria-practices.html
Original file line number Diff line number Diff line change
Expand Up @@ -2322,14 +2322,65 @@ <h4>WAI-ARIA Roles, States, and Properties</h4>
<section class="widget" id="table">
<h3>Table</h3>
<p>
Work on drafting this section is tracked by
<a href="https://github.com/w3c/aria-practices/issues/90">issue 90</a>.
Please provide feedback on this section in
<a href="https://github.com/w3c/aria-practices/issues/526">issue 526.</a>
</p>
<p>
This is a place holder for a to-be-written section about data tables.
The grid pattern includes text describing how to choose between using grid and table, and it links to this section.
This section does not necessarily have to be part of the design pattern section.
Like an HTML <code>table</code> element, a WAI-ARIA <a href="#table" class="role-reference">table</a> is a static tabular structure containing one or more rows that each contain one or more cells; it is not an interactive widget.
Thus, its cells are not focusable or selectable.
The <a href="#grid">grid pattern</a> is used to make an interactive widget that has a tabular structure.
</p>
<p>
However, tables are often used to present a combination of information and interactive widgets.
Since a table is not a widget, Each widget contained in a table is a separate stop in the page tab sequence.
If the number of widgets is large, replacing the table with a grid can dramatically reduce the length of the page tab sequence because a grid is a composite widget that can contain other widgets.
</p>
<p class="note">
As with other WAI-ARIA roles that have a native host language equivalent,
authors are strongly encouraged to use a native HTML <code>table</code> element whenever possible.
This is especially important with role <code>table</code> because it is a new feature of WAI-ARIA 1.1.
It is thus advisable to test implementations thoroughly with each browser and assistive technology combination that could be used by the target audience.
</p>
<section class="notoc">
<h4>Examples</h4>
<p><a href="examples/table/table.html">Table Example</a>: ARIA table made using HTML <code>div</code> and <code>span</code> elements.</p>
</section>
<section class="notoc">
<h4>Keyboard Interaction</h4>
<p>Not applicable.</p>
</section>
<section id="table_roles_states_props" class="notoc">
<h4>WAI-ARIA Roles, States, and Properties</h4>
<ul>
<li>The table container has role <a href="#table" class="role-reference">table</a>. </li>
<li>Each row container has role <a href="#row" class="role-reference">row</a> and is either a DOM descendant of or owned by the <code>table</code> element or an element with role <a href="#rowgroup" class="role-reference">rowgroup</a>. </li>
<li>Each cell is either a DOM descendant of or owned by a <code>row</code> element and has one of the following roles:
<ul>
<li><a href="#columnheader" class="role-reference">columnheader</a> if the cell contains a title or header information for the column.</li>
<li><a href="#rowheader" class="role-reference">rowheader</a> if the cell contains title or header information for the row.</li>
<li><a href="#cell" class="role-reference">cell</a> if the cell does not contain column or row header information.</li>
</ul>
</li>
<li>
If there is an element in the user interface that serves as a label for the table, <a href="#aria-labelledby" class="property-reference">aria-labelledby</a> is set on the table element with a value that refers to the labeling element.
Otherwise, a label is specified for the table element using <a href="#aria-label" class="property-reference">aria-label</a>.
</li>
<li>If the table has a caption or description, <a href="#aria-describedby" class="property-reference">aria-describedby</a> is set on the table element with a value referring to the element containing the description.</li>
<li>If the table contains sortable columns or rows, <a href="#aria-sort" class="property-reference">aria-sort</a> is set to an appropriate value on the header cell element for the sorted column or row as described in the section on <a href="#gridAndTableProperties">grid and table properties</a>. </li>
<li>
If there are conditions where some rows or columns are hidden or not present in the DOM, e.g., there are widgets on the page for hiding rows or columns, the following properties are applied as described in the section on <a href="#gridAndTableProperties">grid and table properties</a>.
<ul>
<li><a href="#aria-colcount" class="property-reference">aria-colcount</a> or <a href="#aria-rowcount" class="property-reference">aria-rowcount</a> is set to the total number of columns or rows, respectively. </li>
<li><a href="#aria-colindex" class="property-reference">aria-colindex</a> or <a href="#aria-rowindex" class="property-reference">aria-rowindex</a> is set to the position of a cell within a row or column, respectively. </li>
</ul>
</li>
<li>If the table includes cells that span multiple rows or multiple columns, then <a href="#aria-rowspan" class="property-reference">aria-rowspan</a> or <a href="#aria-colspan" class="property-reference">aria-colspan</a> is applied as described in <a href="#gridAndTableProperties">grid and table properties</a>.</li>
</ul>
<p class="note">
If rows or cells are included in a table via <a href="#aria-owns" class="property-reference">aria-owns</a>,
they will be presented to assistive technologies after the DOM descendants of the <code>table</code> element unless the DOM descendants are also included in the <code>aria-owns</code> attribute.
</p>
</section>
</section>

<section class="widget" id="tabpanel">
Expand Down
4 changes: 4 additions & 0 deletions examples/table/css/table.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.annotate{
font-style: italic;
color: #366ED4;
}
170 changes: 170 additions & 0 deletions examples/table/table.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Table Example | WAI-ARIA Authoring Practices 1.1</title>

<!-- Core js and css shared by all examples; do not modify when using this template. -->
<link rel="stylesheet" href="https://www.w3.org/StyleSheets/TR/2016/base.css">
<link rel="stylesheet" href="../css/core.css">
<script src="../js/examples.js"></script>
<script src="../js/highlight.pack.js"></script>
<script src="../js/app.js"></script>

<!-- css for this example. -->
<link href="css/table.css" rel="stylesheet">
</head>
<body>
<h1>Table Example</h1>
<p>
<strong>NOTE:</strong> This example page is not complete and is not yet ready for review.
Work on this page is tracked in
<a href="https://github.com/w3c/aria-practices/issues/242">issue 242.</a>
</p>
<p>
The below example illustrates an implementation of the WAI-ARIA
<a href="../../#table">table design pattern.</a>
Note that when possible, using a native HTML <code>table</code> element is recommended.
</p>
<p>Similar examples include: </p>
<ul>
<li><a href="../grid/LayoutGrids.html">Layout Grid Examples</a>: Three example implementations of grids that are used to lay out widgets, including a collection of navigation links, a message recipients list, and a set of search results.</li>
<li><a href="../grid/dataGrids.html">Data Grid Examples</a>: Three example implementations of grid that include features relevant to presenting tabular information, such as content editing, sort, and column hiding.</li>
<li><a href="../grid/advancedDataGrid.html">Advanced Data Grid Example</a>: Example of a grid with behaviors and features similar to a typical spreadsheet, including cell and row selection.</li>
</ul>

<section>
<h2 id="ex_label">Example</h2>
<div role="separator" id="ex_start_sep" aria-labelledby="ex_start_sep ex_label" aria-label="Start of"></div>
<div id="ex1">
<div role="table" aria-label="Students" aria-describedby="students_table_desc">
<div id="students_table_desc">Students currently enrolled in WAI-ARIA 101 for the coming semester</div>
<div role="rowgroup">
<div role="row">
<span role="columnheader">First Name</span>
<span role="columnheader">Last Name</span>
<span role="columnheader">Company</span>
<span role="columnheader">Address</span>
</div>
</div>
<div role="rowgroup">
<div role="row">
<span role="cell">Fred</span>
<span role="cell">Jackson</span>
<span role="cell">Acme, Inc.</span>
<span role="cell">123 Broad St.</span>
</div>
<div role="row">
<span role="cell">Sara</span>
<span role="cell">James</span>
<span role="cell">Acme, Inc.</span>
<span role="cell">123 Broad St.</span>
</div>
</div>
</div>
</div>
<div role="separator" id="ex_end_sep" aria-labelledby="ex_end_sep ex_label" aria-label="End of"></div>
</section>

<section>
<h2 id="kbd_label">Keyboard Support</h2>
<p>Not Applicable</p>
</section>

<section>
<h2 id="rps_label">Role, Property, State, and Tabindex Attributes</h2>
<table aria-labelledby="rps_label" class="data attributes">
<thead>
<tr>
<th scope="col">Role</th>
<th scope="col">Attribute</th>
<th scope="col">Element</th>
<th scope="col">Usage</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row"><code>table</code></th>
<td></td>
<td><code>div</code></td>
<td>Identifies the element containing the table structure.</td>
</tr>
<tr>
<td></td>
<th scope="row">
<code>aria-label=&quot;Students&quot;</code>
</th>
<td><code>div</code></td>
<td>Provides an accessible name for the table.</td>
</tr>
<tr>
<td></td>
<th scope="row">
<code>aria-describedby=&quot;IDREF&quot;</code>
</th>
<td><code>div</code></td>
<td>Refers to the element that serves as the caption for the table.</td>
</tr>
<tr>
<th scope="row"><code>rowgroup</code></th>
<td></td>
<td><code>div</code></td>
<td>
<ul>
<li>Identifies the elements that serve as containers for the table header and table body rows.</li>
<li>Unlike HTML, WAI-ARIA does not include separate roles for the table header and table body row sets.</li>
</ul>
</td>
</tr>
<tr>
<th scope="row"><code>row</code></th>
<td></td>
<td><code>div</code></td>
<td>Identifies each element that contains the cells for a row.</td>
</tr>
<tr>
<th scope="row"><code>columnheader</code></th>
<td></td>
<td><code>span</code></td>
<td>Identifies elements that serve as a cell containing a column label.</td>
</tr>
<tr>
<th scope="row"><code>cell</code></th>
<td></td>
<td><code>span</code></td>
<td>Identifies elements containing content for a single cell.</td>
</tr>
</tbody>
</table>
</section>

<section>
<h2>Javascript and CSS Source Code</h2>
<!-- After the js and css files are named with the name of this example, change the href and text of the following 2 links to refer to the appropriate js and css files. -->
<ul>
<li>
CSS:
<a href="css/table.css" type="tex/css">table.css</a>
</li>
<li>
Javascript: Not applicable.
</li>
</ul>
</section>

<section>
<h2 id="sc1_label">HTML Source Code</h2>
<div role="separator" id="sc1_start_sep" aria-labelledby="sc1_start_sep sc1_label" aria-label="Start of"></div>
<pre><code id="sc1"></code></pre>
<div role="separator" id="sc1_end_sep" aria-labelledby="sc1_end_sep sc1_label" aria-label="End of"></div>
<script>
sourceCode.add('sc1', 'ex1');
sourceCode.make();
</script>
</section>
</main>
<nav>
<a href="../../#table">Table Design Pattern in WAI-ARIA Authoring Practices 1.1</a>
</nav>
</body>
</html>

0 comments on commit dec93f6

Please sign in to comment.