1

I have two divs which I´m doing a load by Ajax in everyone. If I write both like this.

<div id="informCandidacyId"/>
<div id="idDivFiles"/>

The load process of both happens because I can debug the calls to my controllers, but onyl one view is added to the DOM.

In the other hand if I write the divs like this.

<div id="informCandidacyId"></div>
<div id="idDivFiles"></div>

The both load calls works perfectly.

So my question is, what is the difference when we are loading html code between close the tag in the declaration or do it in another tag?

Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
paul
  • 12,873
  • 23
  • 91
  • 153

2 Answers2

1

The difference is that <div> is not a self closing tag. While some browsers may accept and correct your code, it won't validate, and is bad practice.

W3C Spec

Jacques ジャック
  • 3,682
  • 2
  • 20
  • 43
0

According to the HTML5 specification, the <div> element is a normal element and only void elements (like <br>) or foreign elements (from MathML and SVG namespace) could have a "/" (U+002F) character in the start tag.

So your code is invalid and this explains the difference in the load process.

Ortomala Lokni
  • 56,620
  • 24
  • 188
  • 240