This week, Support Lead, Helen Grimbly will be looking at diagnostics related to close tags, which can affect accessibility.
If there is a missing close tag in a web page where it is expected, this can have many different unwanted consequences. For example a missing div tag could mean some content could visually appear in an unplanned area of the web page. Different browsers could attempt to resolve the missing tag but may not do this accurately, and in turn the content could then be interpreted incorrectly to someone using a screen reader.
Issues related to close tags will raise an Accessibility diagnostic:
H74: Ensuring that opening and closing tags are used according to specification
Points for resolving unclosed tags diagnostics:
1. Make sure that the element is closed if the specification in use requires a close tag.
HTML allows you to omit close tags for some elements such as <p>, but not all.
XHTML requires close tags for everything.
2. Body content such as <span> inside the <head> element will cause an implicit close of the body (and therefore implicit close of the head). This could mean that declarations such as scripts that follow the span tag, would not appear in the header where they should. This also means that the </head> close tag, when it appears, will be an error.
3. <p> cannot be nested in a <p> paragraph, as this will implicitly close the first <p> declared. This would raise the following Code Quality diagnostic:
Diagnostic: file/html/closingunopened: A redundant close tag was found
Incorrect nesting example:
Examples that are OK in HTML:
If the paragraph end tag </p> was missing with specification XHTML, then the following Code Quality diagnostic would be raised:
Diagnostic: file/html/missingclose: An element is missing the required close tag