如何找到未关闭的div标签 [英] How to find the unclosed div tag
问题描述
有什么建议吗?
如前所述,通过 W3C验证器运行您的代码非常棒,但如果您的页面很复杂,你仍然可能不知道在哪里可以找到打开的div。
我喜欢使用制表符来缩进我的代码。它保持视觉上的组织,以便这些问题更容易找到,孩子,兄弟姐妹,父母等......他们会更明显。
编辑:另外,我将使用一些HTML注释标记复杂区域中的结束标记。
< body>
< div>
主要内容
< div>
Div#1内容
< div>
div的子元素#1
< div>
div#1孩子的孩子
< / div><! - // div#1孩子的孩子关闭// - >
< / div><! - //关闭div#1的子项// - >
< / div><! - //关闭div#1 // - >
< div>
Div#2内容
< / div>
< div>
Div#3内容
< / div>
< / div><! - //关闭主要内容div // - >
< / body>
A unclosed div problem almost make me crazy. It is very difficult to track especially when the page is long and complex.
Any suggestions?
As stated already, running your code through the W3C Validator is great but if your page is complex, you still may not know exactly where to find the open div.
I like using tabs to indent my code. It keeps it visually organized so that these issues are easier to find, children, siblings, parents, etc... they'll appear more obvious.
EDIT: Also, I'll use a few HTML comments to mark closing tags in the complex areas. I keep these to a minimum for neatness.
<body>
<div>
Main Content
<div>
Div #1 content
<div>
Child of div #1
<div>
Child of child of div #1
</div><!--// close of child of child of div #1 //-->
</div><!--// close of child of div #1 //-->
</div><!--// close of div #1 //-->
<div>
Div #2 content
</div>
<div>
Div #3 content
</div>
</div><!--// close of Main Content div //-->
</body>
这篇关于如何找到未关闭的div标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!