简体   繁体   English

我想链接 html 和 css 文件。 但不起作用

[英]i wanted to link the html and css files. but does not work

<html>

<head>

<title> HELLO </title>

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

</head>

<body>

<h1> WELCOME TO THE NEW WORLD </h1>

<p>  This is the world of Oppurtunities </p>

</body>

</html>

the css file is below. css文件在下面。

body{
    background-color: darkslategrey;
    color: azure;
     }

h1{
    color: coral;
     }

You question is pretty vague but your path to the CSS is probably off.你的问题很模糊,但你的 CSS 路径可能已经关闭。

Without more info on your dev environment this is my best suggestion.如果没有关于您的开发环境的更多信息,这是我最好的建议。

Change your CSS link to...将您的 CSS 链接更改为...

<link rel="stylesheet" type="text/css" href="../back.css"/> Notice the ./back.css <link rel="stylesheet" type="text/css" href="../back.css"/>注意 ./back.css

This may not be the correct path to the file but your issue lies in your relative path .这可能不是文件的正确路径,但您的问题在于您的相对路径 It all depends on your file structure.这完全取决于您的文件结构。

Basic Examples基本示例

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

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

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

Perhaps putting the css file into a folder might work out.也许将 css 文件放入文件夹可能会奏效。

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

That usually does the trick, let us know ;)!这通常可以解决问题,让我们知道;)!

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

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