我的 html 和 css 不会链接 css 假设使标题上的 Hayes 和 Ash 字样变为红色。我的代码:
<!DOCTYPE html>
<html style="background-color:#FFA100;>
<head>
<link rel="stylesheet" type="text/css" href="C:\Documents and Settings\Test.DOBRUSKY\Desktop\stylesheet.css"/>
<title>Hayes and Ash</title>
</head>
<body>
<h1>Hayes and Ash<h1>
<div id="hayes">
<img src="http://i.imgur.com/xXSDVAm.jpg?1"/>
<p>I am Hayes harharhar</p>
</div>
<div id="ash">
<img src="http://i.imgur.com/zcBLpU6.jpg?1"/>
<p>This is Ash I am very fluffy!</p>
</div>
</body>
</html>
最佳答案
href 链接:
href="C:\Documents and Settings\Test.DOBRUSKY\Desktop\stylesheet.css"
应该是URL,而不是本地文件系统路径。并且它可以是相对于 HTML 文档的位置,例如:
href="stylesheet.css"
或
href="http://www.example.com/somewhere/out/there/stylesheet.css"
关于HTML 和 CSS 不会链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19851268/