繁体   English   中英

HTML文件未加载style.css文件

[英]HTML file does not load style.css file

我正在做一个小型网页,但现在遇到了一个小问题。 即使将它们放置在同一文件夹中,我的html文件也不会加载样式文件。 我在w3schools中检查了css文件,它工作正常。 我知道这个话题已经存在,但是我无法通过阅读这些内容解决问题。 我的html编码看起来像这样

<html>
 <head>
  <title>Smile's app</title>
  <link href="style.css" rel="stylesheet" type="text/css" />
 </head>

 <body>
 <h2>Hello Dude</h2>
   <a href="http://www.w3schools.com/html/">Visit our HTML tutorial</a> 

   <blockquote>Nerds like us are allowed to be unironically enthusiastic about stuff. Nerds are allowed to love stuff - like, jump-up-and-down-in-your-chair-can't-control-yourself love it. When people call other people nerds, mostly what they're saying is "You like stuff", which is not a good insult at all. Like, "You are too enthusiastic about the miracle of human consciousness".</blockquote>
   <div class="cite">John Green</div>

   <li><a href="static/indexx.html">page2</a></li>

 </body>
</html>

CSS编码看起来像这样

blockquote {
  background-color: black;
  color: yellow;
  padding: 10px;
}

.cite {
  text-align: right;
  font-weight: bold;
  font-size: x-large;
}

否,我通过网络控制台样式编辑器发现存在以下错误

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>404 Not Found</title>
<h1>Not Found</h1>
<p>The requested URL was not found on the server.  If you entered the URL manually please check your spelling and try again.</p>

我确实希望有人能帮助我。

检查以下内容。(尽管您可能已经检查过,或者看起来很傻)

  • 确保CSS文件与HTML位于同一目录中

  • 确保CSS文件的名称为style.css

如果所有方法都不起作用,则将CSS添加到head标签中的style标签中,如下所示:

<html>
 <head>
  <title>Smile's app</title>
  <style>
  blockquote {
    background-color: black;
    color: yellow;
    padding: 10px;
  }

  .cite {
    text-align: right;
    font-weight: bold;
    font-size: x-large;
  }
  </style>
 </head>

 <body>
 <h2>Hello Dude</h2>
   <a href="http://www.w3schools.com/html/">Visit our HTML tutorial</a> 

   <blockquote>Nerds like us are allowed to be unironically enthusiastic about stuff. Nerds are allowed to love stuff - like, jump-up-and-down-in-your-chair-can't-control-yourself love it. When people call other people nerds, mostly what they're saying is "You like stuff", which is not a good insult at all. Like, "You are too enthusiastic about the miracle of human consciousness".</blockquote>
   <div class="cite">John Green</div>

   <li><a href="static/indexx.html">page2</a></li>

 </body>
</html>

希望这会有所帮助(尽管这很愚蠢和基本)。

注意:即使最小,最细微的基本内容也可以有所作为。

我还建议您查看文件夹结构。

您是在本地环境中还是在偏远地区进行开发?

您正在使用某种Web服务器(例如Apache)还是通过file:///访问文件?

正如你所说:

在浏览器的“样式编辑器”中,我得到以下信息

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <title>404 Not Found</title> <h1>Not Found</h1> <p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p> 

如何进行这些更改?

在我看来,服务器无法访问css文件。 您是否检查了访问权限和文件的所有者?

很抱歉,我现在只能建议这样做,而且您可能已经尝试过使用id,但是我个人认为解决方案必须在文件系统上,因为这两个文件似乎都是正确的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM