Html 检查所有标签是否关闭

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13143716/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 03:38:04  来源:igfitidea点击:

Check If All Tags Are Closed

html

提问by Jon

I have a large dynamic website that is being constructed by PHP. I suspect that one of my components are not closing the HTML tags properly. I have the source output HTML. I am wondering if there is a script, or website, that will tell me if all my tags are closed and such?

我有一个由 PHP 构建的大型动态网站。我怀疑我的一个组件没有正确关闭 HTML 标签。我有源输出 HTML。我想知道是否有脚本或网站可以告诉我我的所有标签是否已关闭等等?

回答by Gianluca Ghettini

Use the W3C Markup Validator Service at http://validator.w3.org/

使用位于http://validator.w3.org/的 W3C 标记验证器服务

回答by Josh Bibb

Try HTML Tidy. Theres a firefox plugin version as well

试试 HTML Tidy。还有一个firefox插件版本

If you work alot in your browser and dont want to jump back and forth to the w3 schools this is a good choice, but like everyone who commented said, the validator is good as well.

如果您在浏览器中工作很多并且不想来回跳到 w3 学校,这是一个不错的选择,但就像评论的每个人所说的那样,验证器也很好。

回答by Alohci

Just for interest, I shall point out that validator.nuis better for checking HTML4 than the W3C validator. Suppose your markup is this:

出于兴趣,我将指出validator.nu比 W3C 验证器更适合检查 HTML4。假设您的标记是这样的:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" 
                 "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <meta content="Test" /
    <title>Test Case</title>
  </head>
  <body>
    <p></p>
  </body>
</html>

The <meta>element clearly isn't closed where it should be, and the result is that the <title>element won't be recognised in browsers.

<meta>元素显然没有在它应该在的地方关闭,结果是该<title>元素将无法在浏览器中被识别。

But give that markup to the W3C validator and it will tell you that it validates. That's because it is based on SGML processing which permits a syntax known a Null End Tag (NET) syntax, which makes it think that the /ends the tag.

但是将该标记提供给 W3C 验证器,它会告诉您它已验证。那是因为它基于 SGML 处理,该处理允许一种称为空结束标记 (NET) 语法的语法,这使得它认为/标记结束。

Browsers do not support NET syntax, and neither does validator.nu, thus correctly flagging the markup as in error.

浏览器不支持 NET 语法,validator.nu 也不支持,因此正确地将标记标记为错误。

For HTML5, both validators are good.

对于 HTML5,两个验证器都很好。