Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<ul> <li><p>In <strong>HTML 4</strong>, <code>&lt;foo /</code> (yes, with no <code>&gt;</code> at all) means <code>&lt;foo&gt;</code> (which leads to <code>&lt;br /&gt;</code> meaning <code>&lt;br&gt;&gt;</code> (i.e. <code>&lt;br&gt;&amp;gt;</code>) and <code>&lt;title/hello/</code> meaning <code>&lt;title&gt;hello&lt;/title&gt;</code>). Browsers did a very poor job of supporting this and <a href="http://www.w3.org/TR/html4/appendix/notes.html#h-B.3.3" rel="noreferrer">the spec advises authors to avoid the syntax</a>.</p></li> <li><p>In <strong>XHTML</strong>, <a href="http://www.w3.org/TR/xml/#d0e2480" rel="noreferrer"><code>&lt;foo /&gt;</code> means <code>&lt;foo&gt;&lt;/foo&gt;</code></a>. This is an <strong>XML</strong> rule that applies to all XML documents. That said, XHTML is often served as <code>text/html</code> which (historically at least) gets processed by browsers using a different parser than documents served as <code>application/xhtml+xml</code>. The W3C provides <a href="http://www.w3.org/TR/xhtml-media-types/#C_2" rel="noreferrer">compatibility guidelines</a> to follow for XHTML as <code>text/html</code>. (Essentially: Only use self-closing tag syntax when the element is defined as EMPTY (and the end tag was forbidden in the HTML spec)).</p></li> <li><p>In <strong>HTML5</strong>, the meaning of <code>&lt;foo /&gt;</code> <a href="https://www.w3.org/TR/html5/syntax.html#start-tags" rel="noreferrer">depends on the type of element</a>.</p> <ul> <li>On HTML elements that are designated as <em>void elements</em> (essentially "An element that existed before HTML5 and which was forbidden to have any content"), end tags are simply forbidden. The slash at the end of the start tag is allowed, but has no meaning. It is just syntactic sugar for people (and syntax highlighters) that are addicted to XML. </li> <li>On other HTML elements, the slash is an error, but error recovery will cause browsers to ignore it and treat the tag as a regular start tag. This will usually end up with a missing end tag causing subsequent elements to be children instead of siblings.</li> <li>Foreign elements (imported from XML applications such as SVG) treat it as self-closing syntax.</li> </ul></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload