【发布时间】:2021-02-18 02:17:36
【问题描述】:
下面是我的 style.css 文件包含的代码
body{
background-color:pink;
font-size: 130%;
}
我的 style_placement.html 文件包含的代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Style Placement</title>
<link rel='stylesheet' href="style.css">
<style>
h2 {color:maroon}
</style>
</head>
<h1>Style Placement header</h1>
<p>This is heading one</p>
<h2>Subheading 1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ex et similique cupiditate dignissimos delectus nulla dolore, eos dolorum quidem excepturi, facere non repellat accusamus, atque? Id voluptate eos et accusantium.</p>
<h2>Subheading 2</h2>
<p style='text-align:center'></p>
</html>
在这里,我什至没有在 html 文件中使用 body 标签,但已经应用了该标签的样式。谁能帮我知道幕后发生了什么? 下面是我的输出在网络浏览器中的截图
【问题讨论】:
-
即使您省略添加
body标签,它也会自动添加以保持一致性。如果您检查您的页面,您将看到您的正文标签等。但我想不建议这样做,因为并非所有浏览器的行为方式都相同。