我不知道为什么我的样式表无法连接到我的HTML程序



我进入我的编码类,由于某种原因,我的样式表无法连接到我的HTML程序。它们都位于同一文件夹中。我使用记事本++

<!DOCTYPE html>
<html lang = "en">
<head>
<link rel="stylesheet" type="text/css" href="styles/default.css/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Khira Kathleen Mcgregor</title>
</head>
<body>
<header>
<h1>Testing Header</h1>
<h2> Testing sub header</h2>
</header>
<nav>
<ul>
<li><a href="#">Menu Option 1</a></li>
<li><a href="#">Menu Option 2</a></li>
</ul>
</nav>
<footer> 
Bazzom bazang... we do the bestest! 
<br/>Designed by &copy;Icabad Enterprises
<br/>
<a href="http://validator.w3.org/check?uri=referer" style = "text-decoration: none">
<img src="images/validation_button_html-blue.png" alt="Validate HTML" />
</a>
<!-- you may need to change the name of your image link to match the one you 
uploaded -->
<a href="http://jigsaw.w3.org/css-validator/check/referer" style = "text-decoration: none">
<img src="images/validation_button_css-blue.png" alt="Validate CSS" />
</a>
</footer>
</body>
</html> 

还有我的样式表:

body
{
/* you better change this stuff */
margin: 300px;
font-family: papyrus;
color: red;
background-color: green;
font-size:600;
}

错误在 html 文件中的第 4 行,您需要以 href 结束引号。

<link rel="stylesheet" type="text/css" href="styles/default.css">

如果您的HTML和CSS文件位于同一文件夹中,则问题出在您的<link>上。

我看到的第一件事是你错过了一个引号。

href="styles/default.css/">

此 href 还指向一个名为"styles"的文件夹,该文件夹将包含 default.css。由于它们位于同一文件夹中,因此您的<link>应如下所示:

<link rel="stylesheet" type="text/css" href="default.css">
The mistake is in the 4th line . If you using Both in the same folder then you should write it this way :
`<link rel="stylesheet" type="text/css" href="./default.css" />`
If in case you have a different folder structure then 
`<link rel="stylesheet" type="text/css" href="./foldername/default.css" />`

最新更新