浏览器会将样式标签从头到尾移动 [英] Browser will move style tags in head to body
问题描述
我在顶部写了样式标签,但浏览器会将其移动到body
并在其顶部保留一个空字符串.在Mac的浏览器中,它将有一个空白空间.
I wrote the style tag in head, but the browser will move it to the body
and leave an empty string on top of it. And it will have an empty space in the browser in Mac.
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body {
margin: 0;
}
</style>
</head>
<body>
<div>123</div>
</body>
</html>
多余的空格是正文中的空字符串(图片中突出显示), 而不是边距或填充,它将在Firefox和Safari中执行相同的操作.
That extra spacing is an empty string in body (highlighted in image), not margin or padding, and it will do the same thing in Firefox and Safari.
我如何摆脱它?
推荐答案
查看源代码后,我了解为什么会发生这种情况,实际上我在您的代码中发现了一个特殊字符. 这是您的代码链接: https://www.w3schools.com/code/tryit. asp?filename = FK89ZCXW8WDC
After View Your Source Code I Get The Idea Why This Happen, actually there is one special character I found In you code. It's your code link: https://www.w3schools.com/code/tryit.asp?filename=FK89ZCXW8WDC
您可以在样式标签开始之前看到特殊字符.
You can see the special character before the style tag start.
这篇关于浏览器会将样式标签从头到尾移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!