Nuw*_*ika 2 html css html5 webpage
我有一个非常简单的网页.
<html>
<head>
<title/>
</head>
<body>
<h1>hello</h1>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
在Chrome和Firefox中打破了我的网页
问题在于自动关闭标题标签,删除TITLE标签或添加标题可以解决问题
<title>Test Page</title>
Run Code Online (Sandbox Code Playgroud)
什么是自动关闭TITLE标签的问题,找不到任何引用说它无效
如果你有一个void元素:
<img />
<br />
Run Code Online (Sandbox Code Playgroud)
然后他们没有内容,因为无处可去.可以将图像视为<div>带有背景图像的空白.
与这些元素相比:
<h1>Hello</h1>
<section>World</section>
Run Code Online (Sandbox Code Playgroud)
其中实际包含的东西(在这种情况下,文本).
<title/>打破页面的原因是因为您需要在网页中使用标题 - 如果您没有标题,则只显示页面的URL,例如:
google.com/index.html
Run Code Online (Sandbox Code Playgroud)
您需要拥有有效的标题,而<title>不是void元素.这就是它破裂的原因.要查看此信息,请访问HTML验证网站(例如https://validator.w3.org)并查看它告诉您的内容.
简而言之 - <title>不是一个空白元素 - 它需要一个开始和结束标记.
编辑:研究向我展示了这个网站,其中说:
Self-closing: No
Run Code Online (Sandbox Code Playgroud)
所以简而言之,它们不是自我封闭的元素.您可以在此处找到自闭元素列表.