Chrome won't load css?

时间:2019-01-18 14:38:52

标签: html css

I am a complete beginner learning HTML and CSS. I am trying to link a css document to my html, but am having no success. The css file is in the same folder as the html. The html loads perfectly, but won't access the css. Can anyone help?

<html>
 <head>
  <title>Practice</title>
  <link rel=“stylesheet” type=“text/css” href=“styles.css” />
 </head>
 <body>
  <h1>XXXX</h1>
  <h3>YYYYYYYY</h3>
  <p>ZZZZZZZZZZZZZZZZZZZZZZ</p>
 </body>
</html>

Is there something wrong with my code, or is it how my computer won't access the files? I am using MacOS Sierra, and TextEdit to create .html and .css files.

1 个答案:

答案 0 :(得分:-1)

您的HTML应该是:

<html>
 <head>
  <title>Practice</title>
  <link rel="stylesheet" href="styles.css">
 </head>

 <body>
  <h1>XXXX</h1>
  <h3>YYYYYYYY</h3>
  <p>ZZZZZZZZZZZZZZZZZZZZZZ</p>
 </body>
</html>

在包含CSS的同一目录中创建一个名为styles.css的文件。

赞:

h1 { 
  display: block;
  font-size: 2em;
  margin-top: 0.67em;
  margin-bottom: 0.67em;
  margin-left: 0;
  margin-right: 0;
  font-weight: bold;
  color:pink
}