html - HTML wont link with CSS. they are both in the same folder
问题描述
This is the HTML:
<!DOCTYPE html>
<head>
<title> navigation practice</title>
<link rel="stylesheets" type="text/css" href="style.css"/>
</head>
<body>
<ul>
<li><a href="#"> HOME</a></li>
<li><a href="#"> ABOUT</a>
<ul>
<li><a>camp sites</a></li>
<li><a>our team</a></li>
<li><a>wildlife</a></li>
<li><a>resources</a></li>
</ul>
</li>
<li><a href="#"> CONTACT</a>
<ul>
<li><a>email</a></li>
<li><a>phone</a></li>
</ul>
</li>
<li><a href="#">things to do</a>
<ul>
<li><a>shops</a></li>
<li><a>activities</a></li>
<li><a>trails</a></li>
</ul>
</li>
<li><a href="#"> MORE</a></li>
</ul>
</body>
</html>
The CSS just has:
body {
background: blue
}
both the HTML and CSS are in the same file. I’ve checked spelling on the link, syntax and any errors in the CSS. I’ve also tried opening the file in a different browser. I have this problem every time I start a new project. I’m using Notepad++.
解决方案
问题出在您的样式表标签上,您在单词末尾添加了一个不必要的“S”,它应该是:
<link rel="
stylesheet
" type="text/css" href="style.css"/>
不是stylesheets
。
而且您忘记在声明和字符集声明之后打开html
标签。<!doctype html>
这是它应该是这样的:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title> navigation practice</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
<!--YOUR CODE HERE-->
</body>
</html>
尝试在此处验证您的代码:https ://www.freeformatter.com/html-validator.html 。它会显示它有什么问题。
推荐阅读
- sharepoint - SharePoint 列类型
- node.js - Universal 中的 NODE_ENV 为“无”,但 process.env 显示“生产”
- python-3.x - 如何获取轮廓区域中心的 x、y 坐标并将鼠标移动到那里或存储坐标
- python - 在 Django admin 中添加新项目,然后重定向到另一个页面
- outlook-addin - OfficeJS Body.setAsync 将破坏电子邮件中的内联图像
- flutter - 减少 Flutter 项目大小
- sql - 简单的字符串比较条件使查询运行时间更长
- javascript - 局域网 IP 地址的 JavaScript 检测
- r - 基于多个通配符的 Sparklyr Spark SQL 过滤器
- android - 未授予 READ_PRIVILEGED_PHONE_STATE 权限