What's the difference between PlaceHolder and <div / ">?
In an ASP.NET project, I have the following HTML:
<asp:PlaceHolder ID="plcTitle" runat="server"></asp:PlaceHolder>
<div id="divStrapline" runat="server" />
which are filled with this code:
if (this.TitlePanel != null)
{
plcTitle.Controls.Add(this.TitlePanel);
}
if (this.Strapline != null)
{
divStrapline.Controls.Add(this.Strapline);
}
Are they both the same? Is it better than the other? Why?a source to share
Empty tags div
(and other container tags such as p
, etc.) closed in the opening element itself (as in <div/>
instead <div></div>
) can lead to problems in some browsers. Browsers can ignore the fact that it is closed with /
and treats it as a new div and thus breaks the subsequent mark.
I once had this problem with Firefox: I was generating html with a mini xml library in python that represented an empty div as <div />
- it broke the rest of my label, confusing it with subsequent divs. I ended up adding comment nodes to empty elements to make sure they have a separate end tag.
a source to share