Developer Corner - Code Quality Diagnostic file/html/tagnotallowed

12 Oct 2020 | Developer Corner

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

This week Helen explains what is meant by the Sitemorse Code Quality diagnostic file/html/tagnotallowed.

file/html/tagnotallowed: A start tag has been found in a position in which that element may not appear

This is a Sitemorse Code Quality error that is raised when a start tag is found in a position which an element may not appear. Please note that the doctype of an HTML document will determine which HTML specification we will compare your HTML against, and therefore which elements are allowed in which order, and how they are used. Please see the following document about Doctypes: 
https://sitemorse.com/blog-article/9472/week-25-technical-service-bulletin-defining-doctype-webpage/

An example of the diagnostic file/html/tagnotallowed is as follows:

Example: Nested lists

Tag 'ul' may not come under tag 'ul'

This error could be raised if a nested list has been created incorrectly. For example: 
<ul> 
  <li>First list</li> 
  <ul> 
    <li>Incorrect nested list</li> 
  </ul> 
</ul>

A <ul> list element cannot appear under another <ul> list element, unless the nested list is contained within <li></li> list tags. This can be corrected to: 
<ul> 
  <li>First list</li> 
  <li> 
    <ul> 
      <li>Correctly nested list</li> 
    </ul> 
  </li> 
</ul>

This Code quality error will affect the score.

If HTML is not used correctly it can affect the way a page can appear in different browsers, and could also affect how screen readers read a page.