4.1. Write a valid HTML code following the formal grammar rules of the DOCTYPE used

Use a valid DOCTYPE for each page and make sure the generated HTML code complies with the formal grammar rules of that DOCTYPE (the choice of DOCTYPE is open).


This DOCTYPE must be placed before the <html> tag.

The following aspects of formal grammar are particularly important:

  • Elements are nested according to their specifications.
  • Elements have complete start and end tags.
  • There are no duplicate attributes on an element.
  • Each id attribute has a unique value on the page.


  • Obsolete HTML elements and attributes and/or those intended for formatting purposes only must not be used.
  • In order to validate grammar rules, it is necessary to check the generated HTML code, by copying it for example into the code inspector (using the F12 shortcut for example) and by pasting it onto the site https://validator.w3.org/nu/#textarea.
    Retrieving the source code of the page (by using the CTRL + U shortcut for example) or copying and pasting the page URL into the validator does not allow to thoroughly test this point.

Find out more


Add a comment

All fields are mandatory.


28 July 2022
Added more details on how to check grammar rules

Back to top