HTML 中的多个尖括号有效吗?
validator.w3.org 认为以下有效 HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Test</title>
</head>
<body>
<div>This <<<<<<<<<<<<<<<<<<<<<<b>is</b> a test.</div>
</body>
</html>
它真的有效吗?
validator.w3.org considers the following valid HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Test</title>
</head>
<body>
<div>This <<<<<<<<<<<<<<<<<<<<<<b>is</b> a test.</div>
</body>
</html>
Is it really valid?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
是的,标签只会被视为附加文本。它不是 HTML 标记的一部分。
它只会打印
这没什么问题。
Yes, the tag would just be treated as additional text. It's not part of the HTML tag.
It'd just print
Nothing wrong with that.
此代码已使用 W3C 验证器成功验证。该页面将按预期显示在所有主要浏览器(Firefox、Opera、Chrome 和 Internet Explorer)上。
您可以在此处查看结果:http://validator.w3.org/
This code is successfully verified using the W3C Validator. And the page will be shown on all major browsers (Firefox, Opera, Chrome and Internet Explorer) as expected.
You can check the result here: http://validator.w3.org/
验证为 HTML 时允许,但验证为 XHTML 时不允许。
这里您需要使用
<
和>
,无论如何,这是最佳实践。When validating as HTML it is allowed, but not when validating as XHTML.
Here you need to use
<
and>
, which is best practise anyway.我在 w3c 中测试了你的代码。根据 w3c 标准,它是完全有效的:)
但使用 HTML 实体始终是一个很好的实践。可以写“<”或“<”尽管写了“>”。我们使用 HTML 实体来确保所有浏览器和平台的准确结果。
参考:http://www.w3schools.com/html/html_entities.asp
最好的问候,
图希德
I tested your code in w3c. It's perfectly valid according to w3c standard :)
But it's always a good practice to work with HTML entities. You can write "<" or "<" in spite of writing ">". We use HTML entities to ensure exact result for all browsers and platforms.
Reference:http://www.w3schools.com/html/html_entities.asp
Best Regards,
Touhid