Content management systems with WYSIWYG editors are great tools, in that they enable easy publication by those not familiar with HTML. But that same ease of use may enable non-valid or inaccessible HTML markup. Some CSS rules have been suggested by others to enforce good markup by penalizing bad markup. For instance, use of depreciated tags can be forced to display as big, bold and red:
font {
font-size: 50px;
font-weight: bold;
color: red;
}
You may view this as overly confrontational. But I just conceived a way to use CSS (with a bit more constraint), to enforce accessible markup. One of the most important accessible practices (and easiest to implement) is the inclusion of alternate text for images. The following HTML demonstrates proper inclusion of the required alt attribute.
<img src="/pic.jpg" alt="Jeff's mug" />
If someone uses a content management system to display an image that is missing this attribute, you can use your CSS stylesheet to suppress the image from displaying with the following code:
img {
visibility: hidden;
}
img[alt] {
visibility: visible;
}
A few thoughts result from this implementation. Not every screen reader will ignore hidden elements, but that is not the point. If an image is not accessible to everyone (by way of an alt tag), this ensures that the publisher of the content recognizes that same inaccessibility.
Second, visibility is used for several reasons.
- It does not conflict with your other
displayrules that may give images inline or block value in different context; visibilityleaves a void of content, making it clear to the publisher that the image is not displaying; anddisplaycan be turned off with a value ofnone, but there is no valid value for turning it back on (without contextual knowledge of whetherblockorinlineis appropriate).
Lastly, this proposal breaks in Internet Explorer 6, as IE6 does not understand attribute selectors. This can be resolved with the inclusion of conditional comments in your document head. For example:
<!--[if lt IE 7]>
<style>
img {
visibility: visible;
}
</style>
<![endif]-->
Now images will display as normal in IE6.


