title: Are (non-void) self-closing tags valid in HTML5?
body: <p>The <a href="https://validator.w3.org/" rel="noreferrer">W3C validator</a> (<a href="http://en.wikipedia.org/wiki/W3C_Markup_Validation_Service" rel="noreferrer">Wikipedia</a>) doesn't like self-closing tags (those that end with “<code>/&gt;</code>”) on <a href="https://html.spec.whatwg.org/multipage/syntax.html#elements-2" rel="noreferrer">non-void</a> elements. (<a href="https://html.spec.whatwg.org/multipage/syntax.html#void-elements" rel="noreferrer">Void elements</a> are those that may not ever contain any content.) Are they still valid in HTML5?</p>
  <p>Some examples of <em>accepted</em> void elements:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;br /&gt;
  &lt;img src=&quot;&quot; /&gt;
  &lt;input type=&quot;text&quot; name=&quot;username&quot; /&gt;
  </code></pre>
  <p>Some examples of <em>rejected</em> non-void elements:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;div id=&quot;myDiv&quot; /&gt;
  &lt;span id=&quot;mySpan&quot; /&gt;
  &lt;textarea id=&quot;someTextMessage&quot; /&gt;
  </code></pre>
  <sub>
  <b>Note:</b> <br>
  The W3C validator actually accepts void self-closing tags: the author originally had a problem because of a simple typo (<code>\></code> instead of <code>/></code>); however, self-closing tags are not 100% valid in HTML5 in general, and the answers elaborate on the issue of self-closing tags across various HTML flavors.
  </sub>