Technique H94:Ensuring that elements do not contain duplicate attributes
About this Technique
This technique relates to 4.1.1: Parsing (Sufficient, together with H74: Ensuring that opening and closing tags are used according to specification and H93: Ensuring that id attributes are unique on a Web page when used for ensuring that Web pages can be parsed).
This technique applies to all HTML pages.
Description
The objective of this technique is to avoid key errors that are known to cause problems for assistive technologies when they are trying to parse content that has duplicate attributes on the same element. This can be checked manually, or by using HTML's mechanism to specify the technology and technology version and validating the document for this condition. There are several validators that the developer can use; validation reports generally mention this type of error. The document type declaration is not strictly necessary for this type of evaluation, but specifying the document type declaration makes it easier to use a validator.
Examples
Example 1: HTML Validators
HTML pages include a document type declaration (sometimes referred to as !DOCTYPE
statement). The developer can use offline or online validators (see Resources below) to check that attributes are only used once on an element. The W3C validator, for example, will report Error duplicate attribute [attribute name] when it encounters the second definition of the same attribute on an element.
Related Resources
No endorsement implied.
- Do not forget to add a doctype by the W3C Quality Assurance Initiative explains what doctypes are and why you should use them.
- Recommended DTDs to use in your Web document by the W3C Quality Assurance Initiative is a list of commonly used declarations.
- How do I validate my code or check for possible errors? describes the tools in the free editor HTML-Kit for checking HTML, CSS and XML.
For other resources, see G134: Validating Web pages.
Tests
Procedure
- Check that no attribute occurs more than once on any element
Expected Results
- Check #1 is true.
Expected Results
- Check #1 is true.
Test Rules
The following are Test Rules related to this Technique. It is not necessary to use these particular Test Rules to check for conformance with WCAG, but they are defined and approved test methods. For information on using Test Rules, see Understanding Test Rules for WCAG Success Criteria.