简体   繁体   English

CSS / HTML链接问题

[英]Issue with CSS/ HTML Link

Could anyone tell me why my page isn't linking to the CSS ? 谁能告诉我为什么我的页面没有链接到CSS I have both HTML and CSS file in the same folder. 我在同一文件夹中同时包含HTMLCSS文件。

Here's my HTML : 这是我的HTML

<!DOCTYPE html>
<html>
  <head>
      <link rel="stylesheet" type = "text/css" href="style.css">
      <title> Flying Fish Painting Company </title>
  </head>
  <body>
     <h1> Flying Fish Painting Company </h1>
  </body> 
</html>

And this is my CSS : 这是我的CSS

h1{
    color:blue;
  }

It works fine for me. 这对我来说可以。

If I put both files in the same folder then it also works 如果我将两个文件放在同一个文件夹中,那么它也可以工作

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

if you put your CSS file in a different folder that time. 如果您当时将CSS文件放在其他文件夹中。

Syntax: 句法:

<link rel="stylesheet" type="text/css" href="foldername/filename.css">

You should write: 您应该写:

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

Could you check the spaces: 您能否检查一下空格:

type = "text/css"

change to: 改成:

type="text/css"

Is this your exact html code or just an example? 这是您确切的html代码还是一个示例?

There are a couple of spaces before and after your = on the type you should remove. 在您应删除的类型上,=前后有两个空格。
Personally I find it better to put all css in a subfolder. 我个人认为最好将所有css放在一个子文件夹中。 It shouldn't make a difference however it makes for easier organization. 它不应该有所作为,但是可以简化组织。
For a single css style like that I would just put it in line the html unless this is something you want across several html files. 对于像这样的单个css样式,除非将其放在多个html文件中,否则我会将其放在html行中。

There is nothing wrong with this code except the spaces mentioned above. 除了上面提到的空格,此代码没有其他问题。 Works fine for me. 对我来说很好。 Check for typos and make sure it is in the same folder. 检查拼写错误,并确保它位于同一文件夹中。

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

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