关闭标记中的HTML ID属性? [英] HTML ID attribute in close tag?

查看:77
本文介绍了关闭标记中的HTML ID属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这段代码是否正确,其中ID为close div:

Is this code okay, where I ID a close div:

<html>
<body>
<div id="main">

</div id=main">
</body>
</html>


推荐答案

否。 id 属性应该只在开始标签。

No. The id attribute should only be in the opening tag.

如果你这样做是为了可读性,你可能想使用HTML注释和标签来源:

If you're doing this for readability, you might want to use HTML comments and tabified source:

<html>
    <body>
        <div id="main">

        </div>
        <!-- close main div -->
    </body>
</html>

这篇关于关闭标记中的HTML ID属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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