如何找到未关闭的div标签 [英] How to find the unclosed div tag

查看:726
本文介绍了如何找到未关闭的div标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个未公开的div问题几乎让我发疯。这是非常困难的,尤其是当页面很长和复杂时。



有什么建议吗?

解决方案

如前所述,通过 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆