Introduction

In this article am explaining parsing modes/syntax used in HTML5 for various functions and how these parsing modes work and what they do.
HTML5 | Syntax
HTML5 has two syntaxes; sometimes we call these syntaxes parsing modes. These are:
HTML5 | Syntax
The basic difference between the functionalities of these two modes depends on whether the document is served with a content-type.
Content-Type for HTML
text/HTML
Content-Type for XML
application/xml+xhtml
Working | Parsing Modes
The functionality of the parsing modes depends only upon the content-type, so there exist the following two conditions respectively:
Parsing Modes
XHTML5 : HTML5's HTML Syntax
If it's served as text/html then the following rules will be applied:
Code Snippet | Example
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8"/>
  5. <title>NEW</title>
  6. <link rel=Stylesheet href="style.css" type="text/css" />
  7. <style>
  8. body
  9. {
  10. background: oceangreen;
  11. }
  12. </style>
  13. </head>
  14. <body>
  15. <p>
  16. <img src="new.png" alt="new"/>
  17. <!--anything u want to include in para-->
  18. </p>
  19. <script src="new1.js"/>
  20. </body>
  21. </html>
XHTML5 : HTML5's XML Syntax
If it's served as application/xml+html then the following rules will be applied:
Code Snippet | Example
  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta charset="utf-8"/>
  5. <title>NEW</title>
  6. </head>
  7. <body>
  8. <p>
  9. <img src="new.png" alt="new"/>
  10. <!--anything u want to include in para-->
  11. </p>
  12. <script src="new1.js"/>
  13. </body>
  14. </html>