Skip to content

Proposed Attribute is not duplicated

Description

This rule checks that HTML and SVG starting tags do not contain duplicated attributes.

Applicability

This rule applies to any starting tag in an HTML or SVG document.

Note: This rule cannot be tested on the DOM Tree because the browser removes duplicates of any attribute that is already present on an element.

Expectation

For each test target, there are no duplicated attributes.

Assumptions

There are currently no assumptions.

Accessibility Support

There are no major accessibility support issues known for this rule.

Background

Bibliography

Accessibility Requirements Mapping

Input Aspects

The following aspects are required in using this rule.

Test Cases

Passed

Passed Example 1

Open in a new tab

This img element contains no duplicated attributes.

<img src="/test-assets/shared/w3c-logo.png" alt="W3C logo" />

Passed Example 2

Open in a new tab

This br element contains no attributes, so there is no duplicated attribute.

<br />

Passed Example 3

Open in a new tab

This input element contains three different attributes, two of them being empty.

<input type="checkbox" disabled readonly />

Passed Example 4

Open in a new tab

This SVG element contains no attributes.

<svg>
	<line x1="0" y1="0" x2="200" y2="200" style="stroke-width:2" />
</svg>

Passed Example 5

Open in a new tab

This script element contains duplicated attributes, but they are ignored because they are placed within the script tag.

<script>
	var foo = '<img src="/test-assets/shared/w3c-logo.png" alt="" alt="W3C logo" />'
</script>

Failed

Failed Example 1

Open in a new tab

This img element contains a duplicated alt attribute.

<img src="/test-assets/shared/w3c-logo.png" alt="" alt="W3C logo" />

Failed Example 2

Open in a new tab

This input element contains a duplicate disabled attribute.

<input type="checkbox" disabled="disabled" disabled readonly />

Failed Example 3

Open in a new tab

This line element contains duplicate x1 and duplicate y1 attributes.

<svg>
	<line x1="0" y1="0" x1="200" y1="200" style="stroke-width:2" />
</svg>

Inapplicable

Inapplicable Example 1

Open in a new tab

This code is XML, not HTML or SVG.

<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:earl="http://www.w3.org/ns/earl#">
  <earl:TestResult rdf:about="#result"></earl:TestResult>
</rdf:RDF>

Inapplicable Example 2

Open in a new tab

This code is JavaScript, not HTML or SVG.

var foo = '<img src="/test-assets/shared/w3c-logo.png" alt="W3C logo" />'

Glossary

Outcome

An outcome is a conclusion that comes from evaluating an ACT Rule on a test subject or one of its constituent test target. An outcome can be one of the three following types:

Note: A rule has one passed or failed outcome for every test target. When there are no test targets the rule has one inapplicable outcome. This means that each test subject will have one or more outcomes.

Note: Implementations using the EARL10-Schema can express the outcome with the outcome property. In addition to passed, failed and inapplicable, EARL 1.0 also defined an incomplete outcome. While this cannot be the outcome of an ACT Rule when applied in its entirety, it often happens that rules are only partially evaluated. For example, when applicability was automated, but the expectations have to be evaluated manually. Such “interim” results can be expressed with the incomplete outcome.

Rule Versions

This is the first version of this ACT rule.

Implementations

There are currently no known implementations for this rule. If you would like to contribute an implementation, please read the ACT Implementations page for details.

Back to Top

This is an unpublished draft preview that might include content that is not yet approved. The published website is at w3.org/WAI/.