The following is a succinct guide for the syntax rules of the eXtensible Markup Language (XML):

  1. All XML elements must have a closing tag

    <p>This is a paragraph</p>
    
  2. Comments in XML

    <!-- This is a comment -->
    
  3. XML tags are case sensitive

    <TITLE>This example is incorrect</title>  <!-- INCORRECT -->
    
    <title>This example is correct</title>
    
  4. XML elements must be properly nested

    <strong><em>This text is important and emphasized</strong></em>
        <!-- INCORRECT because closing em tag appears out of order -->
    
    <strong><em>This text is important and emphasized</em></strong>
    
  5. XML documents must have a root element

    XML documents must contain one element that is the parent of all other elements. This element is called the root element.

    <html>
      <head>
        <title>Title</title>
      </head>
    </html>
    
  6. XML attribute values must be quoted

    <img src=image.png />
        <!-- INCORRECT because `image.png` is not quoted -->
    
    <img src="image.png" />
    
  7. Special characters in XML

    <code>if salary < 1000:</code>
        <!-- INCORRECT because `<` confused with start of tag -->
    
    <code>if salary &lt; 1000:</code>
    
    Entity Symbol Description
    &lt; < less than
    &gt; > greater than
    &amp; & ampersand
    &apos; apostrophe
    &quot; quotation mark