Comment by ThunderSizzle

9 months ago

I personally prefer <input /> if only to stop other developers to not try doing <input>content </input>.

There are other tags you can omit the closing tag but yet the opening tag shouldn’t be self-closed.

  <ol>
    <li>one
    <li>two
  </ol>

I think even the final closing ol can be omitted as there are rules to auto close elements when encountering tags that don’t make sense in context.

  • I know that, but many developers don't. I can't wait to see the confusion on why my tag didn't auto-close like a <li> tag.

    Ambiguity can be a dangerous thing, and not closing HTML tags can be a cause of that in my experience.

The term for such "other developers" is "hobbyists".

There are other terms but I won't list them here.

  • Sometimes "other developers" is also "coworkers".

    I've found less ambiguity to be a better thing than not, where possible. Self-closing a tag that can't contain anything is one such example of removing ambiguity for "hobbyists".

    • One would need to know the tag is self-closing in order to put the closing slash in. Right? So if one knows it's self-closing already, why do they need to add the extra weight?

      Makes no sense.

      If one wants to add content to a self-closing element, one has far more problems than we're talking about here.

      3 replies →