【发布时间】:2016-01-19 15:21:49
【问题描述】:
看看我的代码。告诉我我做错了什么。
CSS 文件 - 命名 style.css
#color{
background-color: #yellow;
}
HTML 文件
<!DOCTYPE html>
<html> <link rel=”stylesheet” href=”css/style.css” type=”text/css”>
<head>
</head>
<body>
<div id=“color”> color </div>
<p>My first paragraph.</p>
</body>
</html>
我的 HTML 链接错了吗?
这是更新后的 HTML 文件
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/style.css" type="text/css">
</head>
<body>
<div id="color"> color </div>
<p>My first paragraph.</p>
</body>
</html>
【问题讨论】:
-
去掉#符号:
background-color: #yellow;. -
以下答案应该已经有效。如果仍然没有,我认为问题出在您的 CSS 路径中。验证这个 href="css/style.css" 是正确的路径