开发者

Do I `HAVE` to add a space inside an empty DIV tag?

开发者 https://www.devze.com 2023-01-19 04:20 出处:网络
I was reading a book about AJAX and the writer said that one should always add a space inside of empty div tags so as to not risk compatibility problems in \"some browsers\".

I was reading a book about AJAX and the writer said that one should always add a space inside of empty div tags so as to not risk compatibility problems in "some browsers".

So this would be wrong开发者_如何学C <div></div> and this would be right <div> </div>.

Question: Is he an idiot or does he know something?

Thank you.


He's not an idiot. IE 8 (possibly earlier versions as well?) will subtly mess up your layout if your empty div is really empty; adding a comment seems to be the suggested way of dealing with it, but apparently a space works as well.


i usually add &nbsp; instead of the empty space!


I would add a comment so that nothing is displayed. This does cause problems in ie8 for some reason!

0

精彩评论

暂无评论...
验证码 换一张
取 消