css样式表没有链接到index.html

时间:2013-12-13 18:32:18

标签: html css stylesheet

我正在学习使用html和css来制作关于我的页面。我创建了一个名为blog的文件夹,在那里我有一个名为index.html的文件和一个名为css的文件夹。在css文件夹中,我有一个名为style.css的文件。

出于某种原因,我无法在代码中找到错误,该错误不允许我将样式表链接到索引文件。我只是打开文件测试safari上的代码。

这是我的index.html文件:

<!DOCTYPE html>
<html>
<head>
    <title>Stephanie CD</title>
    <link href="css/style.css" rel="stylesheet">
</head>
<body>
    <h1>Hey! I'm Stephanie</h1>
    <p>how are you doing?</p>
</body>
</html>

这是我的style.css文件:

h1  {
    color: blue;
}
body    {
    background: url("http://i.imgur.com/Gm84ZeZ.jpg?1");
    background-size: cover;
    background-position: center;
    text-align: center;
}

我只是重新启动了所有内容,创建了新文件,现在它可以运行了。不知道出了什么问题。

感谢

2 个答案:

答案 0 :(得分:2)

我在Chrome中测试了我的建议,发现没有请求时髦引号中的资源。

测试是尝试使用和不使用时髦的引号加载并查看实际尝试加载的文件,只需创建一个HTML文档:

<link href=“css/style-1.css” rel=“stylesheet”>
<link href="css/style-2.css" rel="stylesheet">

然后在开发人员工具中查看“网络”标签,以查看浏览器实际请求的文件。

这仍然可能不是您的具体问题,但它对我有用(即样式2.css尝试加载但样式1.css没有)。

答案 1 :(得分:0)

我的情况不一样。

p{
			background: red;
			color: white;
			}
		
h1{		
		background: lightblue;
			color: green; 
		}
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<link href="css files\style.css" type="text/css" rel="stylesheet">
     <!--**IMPORTANT** while on pc I had to mention the full relative 
     path to get the desired output.
     link href="C:\Users\Arun\Documents\css files\style.css" 
     type="text/css" rel="stylesheet" THIS WORKED.-->
</head>
<body>
	<p>this is a simple paragraph.</p>
	<p>this is a simple paragraph.</p>
	<p>this is a simple paragraph.</p>
	<p>this is a simple paragraph.</p>
	<p>this is a simple paragraph.</p>

	<h1>hello, hi</h1>





</body>
</html>

相关问题