← Back to context

Comment by pornel

1 month ago

This syntax is ignored in HTML. The / is thrown away and has no effect.

This non-closing talisman means that <div/> or <script/> are not closed, and will mess up nesting of elements.

In HTML, yes. But I thought the OP was talking about XHTML?

  • No. In XHTML, you are required to close your p and li tags. In HTML, the "self-closing" tag is meaningless. That slash doesn't do anything. You can't self-close a <script> or <div> tag. It only appears to work for tags that are don't allow closing.

    • We aren’t talking about p and li tags which require data to be embedded.

      We are talking about self-contained tags such as br.

      In XHTML (and XML in general) tags absolutely can be open and closed inside the same tag via the method I described:

          <br/>
      

      Look it up if you don’t believe me. But this is correct.

      3 replies →