简体   繁体   English

外部CSS样式表未加载

[英]External CSS Stylesheet not loading

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8"/>
        <link rel="css" type="text/css" href="stylesheet.css"/>
    </head>
    <body>
        <p>
            <strong>C</strong>ascading
            <strong>S</strong>tyle
            <strong>S</strong>heets
        </p>
    </body>
</html>


p {
    color: blue;
    text-decoration: underline;
    }
strong {
    color:red;
    }
body {
    background: aqua;
    }

For some reason this won't load. 出于某种原因,它将无法加载。 I ran it through CSS and HTML validators, but I use developer tools and it shows no css stylesheets attached, and my (very basic) formatting is not being applied. 我通过CSS和HTML验证程序运行了它,但是我使用了开发人员工具,它没有显示任何CSS样式表,并且(我的(非常基本的)格式未得到应用。 I looked at a few other questions and nothing fixed this. 我看了几个其他问题,没有任何解决办法。

Try rel="stylesheet" instead of rel="css" 尝试使用rel="stylesheet"而不是rel="css"

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

And if your file path is correct then it must load css, simple as that 如果文件路径正确,则必须加载CSS,就像这样简单

Try with this format 尝试这种格式

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

Read more at http://www.w3schools.com/tags/att_link_rel.asp http://www.w3schools.com/tags/att_link_rel.asp上阅读更多内容

Let me if it works 如果可以的话让我

HTML DOC HTML文档

<!DOCTYPE html>
    <html lang="en">
        <head>
            <meta charset="UTF-8"/>
           //Change rel to stylesheet and it done
            <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
        </head>
        <body>
            <p>
                <strong>C</strong>ascading
                <strong>S</strong>tyle
                <strong>S</strong>heets
            </p>
        </body>
    </html>

Stylesheet.css 样式表.css

  p {
        color: blue;
        text-decoration: underline;
        }
    strong {
        color:red;
        }
    body {
        background: aqua;
        }

Here is an example: 这是一个例子:

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

To load external css you must include a reference to the css file inside the link tag 要加载外部CSS,您必须在链接标记中包含对CSS文件的引用

Check live demo 查看现场演示

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

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