SC4-1-1-tag-nesting

From Automated WCAG Monitoring Community Group
Jump to: navigation, search

This test belongs to 4.1.1 Parsing.

Status

Version 1

Description

This test checks that tags of an HTML or XHTML document are nested correctly. So that elements that must be closed are, elements that shouldn't be aren't, and that elements are closed in the correct order.

Background


Assumptions

no known assumptions

Test properties

Property Possible values
Test requirement 4.1.1 Parsing
Test mode automatic
Test environment HTML source
Test subject single web page

Test procedure

Selector

Test mode: earl:automatic


Select all opening and closing tags in the HTML document

Step 1: Verify opening tag attributes

Test mode: earl:automatic


  • IF the tag is a closing tag:
    • GO TO step 4

Step 2: Check unclosed opening tags

Test mode: earl:automatic


  • Locate the closing tag that corresponds to the current tag
  • IF there was no closing tag
    • IF the element type requires a closing tag:
      • RETURN SC4-1-1-tag-nesting-fail1
    • IF the document is an XML page AND the tag is not self-closing:
      • RETURN SC4-1-1-tag-nesting-fail2
    • ELSE RETURN SC4-1-1-tag-nesting-pass1


Property Value
TestCase SC4-1-1-tag-nesting
Identifier SC4-1-1-tag-nesting-fail1
Outcome failed
ErrorMessage This element requires a closing tag.
Pointer selector result
Info


Property Value
TestCase SC4-1-1-tag-nesting
Identifier SC4-1-1-tag-nesting-fail2
Outcome failed
ErrorMessage Element must use self-closing syntax.
Pointer selector result
Info


Property Value
TestCase SC4-1-1-tag-nesting
Identifier SC4-1-1-tag-nesting-pass1
Outcome passed
Pointer selector result
Info


Step 3: Check that tags are closed in the right place

Test mode: earl:automatic


  • Make a list childTags of tags that follow the current tag, until it's closing tag
  • IF childTags has an opening tag for each closing tag in the list:
    • return SC4-1-1-tag-nesting-pass2
  • ELSE IF NOT ALL these unopened closing tags does not fail STEP 4:
    • return SC4-1-1-tag-nesting-fail3


Property Value
TestCase SC4-1-1-tag-nesting
Identifier SC4-1-1-tag-nesting-pass2
Outcome passed
Pointer selector result
Info


Property Value
TestCase SC4-1-1-tag-nesting
Identifier SC4-1-1-tag-nesting-fail3
Outcome failed
ErrorMessage Element is incorrectly nested
Pointer selector result
Info


Step 4: Closing tags have a corresponding opening tag

  • IF The current closing tag does not have a corresponging opening tag:
    • Return SC4-1-1-tag-nesting-fail4


Property Value
TestCase SC4-1-1-tag-nesting
Identifier SC4-1-1-tag-nesting-fail4
Outcome failed
ErrorMessage Closing tag does not have a corresponding opening tag
Pointer selector result
Info