css 不会从文件加载

标签 css apache debian

我无法从单独的文件加载 .css。

例如,如果我有 html:

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

<head>

</head>

<body>

<h1>My CSS web page!</h1>
<p>Hello world! This is a W3Schools.com example.</p>

</body>
</html>

CSS 没有加载

但是,如果我在同一个 html 文件中有 css,则 css 会正确加载。我究竟做错了什么?

编辑: 根据几个人的建议,将 HTML 更改为以下代码。还是没有效果。 sytle.css 与我的源 html 位于同一目录中。

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

<body>

<h1>My CSS web page!</h1>
<p>Hello world! This is a W3Schools.com example.</p>

</body>
</html>

CSS 样式表:

<style>
    body
    {
        background-color:#b0c4de;
    }
</style>

最佳答案

您的 link 标签格式不正确,应该位于 head 中(而不是文档的根):

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

应该是(注意 href= 更正):

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

关于css 不会从文件加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14897786/

相关文章:

php - 在 arch linux 中以 root 用户身份在 php 中执行命令

debian - 无法使用 FreeTDS 连接到 Debian 8 上的 MS SQL 2012 数据库

javascript - Bootstrap 模式未在页面加载时显示

javascript - 如何让球击中桨时移动得更快?

css - 从事件日志 4720 中筛选详细信息

linux - Crontab 以不同的方式运行 bash

python - 如何使用 Python 在没有窗口管理器的情况下从命令行界面显示全屏图像

html - 如何在 html 代码样式中显示 handlebars 变量?

apache - 如何编写包装器 - 避免子 shell - 用于 apache2 重写映射或 shell 脚本的脚本?

apache - 在 Hybris 中设置 mod_jk 重定向