This site is a low down on what's going on in my life, what I'm working on, what I'm thinking about, and how I'm feeling about life in general.
Friday, 11 April 2008 08:56
When building an accessible standards-based website, many developers feel it is sufficient to pass their pages through the w3c page checkers for xhtml etc. It is fairly important for your pages to pass these tests as much as possible, however, I believe that you need to go beyond the standards and look at whether or not your markup is suitable for purpose.
What I mean by this is that you need to look at each element on your rendered webpage and ask yourself if you've used the correct markup to display it. Often, designers will use spans to list items, instead of a list object, or div tags to display tabulated data instead of a table.
Whenever you want to display tabulated data, do not be afraid to use a table. The witch hunts of the CSS revolution focused on the use of tables for page layout and structure, but used correctly they are still the most effective way of displaying your data in a flexible grid layout. The question is are you coding your tables correctly? The traditional method of creating a table was as follows:
<table>
<tr><td>Header 1</td><td>Header 2</td></tr>
<tr><td>Metric 1</td><td>100</td></tr>
<tr><td>Metric 2</td><td>200</td></tr>
<tr><td>Metric 3</td><td>300</td></tr>
</table>
This works, but the best practice for creating data tables is:
<table>
<thead>
<tr><th>Header 1</th><th>Header 2</th></tr>
</thead>
<tbody>
<tr><td>Metric 1</td><td>100</td></tr>
<tr><td>Metric 2</td><td>200</td></tr>
<tr><td>Metric 3</td><td>300</td></tr>
</tbody>
<tfoot>
<tr><td>Total</td><td>600</td></tr>
</tfoot>
</table>
This approach makes your code easier to understand by both screen readers and developers alike, plus when css is turned off, your data retains it's structure.
When you cast a critical eye over your site, you might notice that many of your page elements are actually lists. Site navigation is a list of destinations, likewise site maps are better displayed in a list object, about us pages often list statistics. These are all comment situations where list object should be used but are not.
You can craft an effect top level navigation using an unordered list:
<ul>
<li><a href="home.php">Home</a></li>
<li><a href="blog.php">Blog</a></li>
<li><a href="contact.php">Contact Us</a></li>
<li><a href="links.php">Links</a></li>
</ul>
The magic then happens within the CSS.
ul {
display: block;
width: 100%;
overflow: hidden;
list-style: none;
margin: 0px;
padding: 0px;
}
ul li{
display: block;
float: left;
overflow: hidden;
margin: 2px;
padding: 0px;
}
ul li a:link, ul li a:visited {
display: block;
margin: 0px;
padding: 15px;
}
ul li a:hover {
display: block;
margin: 0px;
padding: 15px;
background-color: #CCC;
}
These are just two common areas of markup that are overlooked, but there are many more, It's worth brushing up on the markup available to you so that you can ensure you always choose the best markup for the purpose.