Developer Corner - Closing unopened tag

18 Jan 2021 | General

Helen Grimbly
  • Tweet this item
  • share this item on Linkedin

This week, Support Lead, Helen will explains how to resolve issues of closing an unopened tag.

A 'closingunopened' issue is raised where a page contains a close tag for an element which is not open at that point in the document. Sometimes this can be because of a simple editing error. For example:

<h2></h3>

However it can also occur where a start tag and end tag match, but the element was implicitly closed before the end tag was reached. For example:

<head>  
<div></div> 
</head>

In this example, a <div> tag is not permitted inside a <head> element and HTML defines the </head> tag as optional, so the presence of the <div> tag implicitly closes the <head> element. A diagnostic is raised because, by the time we get to the </head>, the <head> element is no longer open.

The correct way to resolve this is to fix the document structure - e.g. move the <div> to the document body.

In Sitemorse this issue will also raise Accessibility error F70 (Failure of Success Criterion 4.1.1 due to incorrect use of start and end tags or attribute markup).

We recommend if either of these issues are raised, to look at the associated source code SMARTVIEW for that diagnostic in Sitemorse, and examine the code around and preceding the diagnostic, looking out in particular for any incorrectly nested tags.