无法更改.css样式表的背景颜色

时间:2018-07-05 10:07:33

标签: css html5

enter image description here由于某些原因,我无法使用CSS样式表在简单的HTML页面中更改背景颜色。 我的代码没有任何错误,所以这很奇怪。

    <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>Document</title>
    <link rel="stylesheet" type="text/css" href="Website/css/style.css" />
</head>

<body>
    <p>This is some content in the body</p>
</body>
</html>

这是我要在style.css文件中尝试做的事情:

body {
    background-color:black;
}

任何帮助表示赞赏!谢谢!

2 个答案:

答案 0 :(得分:2)

解决了。显然, href 中的路径是错误的! 在给css样式表指定路径时,它开始在位于相同根目录下的文件夹中查找。

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Document</title>
    <link rel="stylesheet" type="text/css" href="css/style.css" />
</head>

<body>
    <p>This is some content in the body</p>
    <p>This is some content in the body</p>
    <p>This is some content in the body</p>
</body>
</html>

答案 1 :(得分:1)

您对href路径有疑问。用“ css / style.css”而不是“ /Website/css/style.css”开始路径

相关问题