Empty Tags vs Content Tags
Some tags like div
, span
and p
need content.
Do not mix text with tags inside a content tag.
Otherwise, formatting and dynamic content modification can get complicated.
With HTML5, empty tags don't need to be closed.
The following examples are equivalent:
Closing empty tags might seem cleaner but it is better to leave them open.
Auto-closing tags might be ignored by some browsers and can cause trouble.
Last updated