1

I was just wondering about a random misc. convention. If you for some reason have an empty div, would you do

<div></div>

or would you do

<div />
Alex Benoit
  • 105
  • 2
  • 9
  • possible duplicate of [Are self-closing tags valid in HTML5?](http://stackoverflow.com/questions/3558119/are-self-closing-tags-valid-in-html5) – Jukka K. Korpela Feb 10 '14 at 07:11

1 Answers1

0

The latter is not valid markup, a div element cannot close itself like img or br

The reason is that a div is considered a non-void element. This means it is meant to have content, even if you leave it empty.

Here is a list of elements which can be void, or self closing

ebolyen
  • 956
  • 2
  • 10
  • 25
  • `
    ` (and `
    `) is valid in XHTML, just not recommended when compatibility with legacy HTML processors is an issue (like on web pages served as text/html).
    – Jukka K. Korpela Feb 10 '14 at 07:13