HTML 中的多个尖括号有效吗?

发布于 2024-12-17 22:25:29 字数 438 浏览 2 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

手心的温暖 2024-12-24 22:25:29

是的,标签只会被视为附加文本。它不是 HTML 标记的一部分。

它只会打印

这个<<<<<<<<<<<<<<<测试。

这没什么问题。

Yes, the tag would just be treated as additional text. It's not part of the HTML tag.

It'd just print

This <<<<<<<<<<<<<<<<<<<<<is a test.

Nothing wrong with that.

盗梦空间 2024-12-24 22:25:29

此代码已使用 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/

暮年 2024-12-24 22:25:29

验证为 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.

叹梦 2024-12-24 22:25:29

我在 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文