简体   繁体   English

HTML未链接到CSS文件

[英]HTML not linking to CSS file

TL;DR: My HTML isn't linking to a stylesheet. TL; DR:我的HTML未链接到样式表。

Right off the bat, sorry for so much code. 马上,对这么多代码感到抱歉。
I have checked other questions, but none had such a strange circumstance as I did. 我检查了其他问题,但没有一个情况像我一样奇怪。

I have a file, loggedIn.html : 我有一个文件loggedIn.html

<html>
        <head>
                <title>Logged in!</title>
                <link rel="stylesheet" href="cgi-bin/style.css">
        </head>

        <body>
                You are now logged in!
                <a href="cgi-bin/logout.php">Logout</a>
        </body>
</html>

Which uses the stylesheet style.css : 使用样式表style.css

body { font-family: Georgia, Goudy, Sabon, serif; }

Along with loggedIn.html , index.html uses style.css : 连同loggedIn.htmlindex.html使用style.css

<html>
<head>
        <title>Welcome!</title>
        <link rel="stylesheet" href="cgi-bin/style.css">
</head>

<body>
        <h2>Welcome to That Guy's Fileshare Server!</h2>
        <hr/>
        Please log in.
        <br/>

        <form action="cgi-bin/login.php" method="POST">
                <p>
                <table border="0">
                                <tr>
                                        <td> <label for="username">Username: </label> </td>
                                        <td> <input type="text" name="username"/> </td>
                                </tr>
                                <tr>
                                        <td> <label for="password">Password: </label> </td>
                                        <td> <input type="password" name="password"/> </td>
                                </tr>
                                <tr>
                                        <td> <input type="submit" value="Submit"> </td>
                                </tr>
                        </table>
                </p>
        </form>
        <br/>
        <a href="register.html">Register</a>
        <br/>
        <a href="note.html">Contact information</a>
</body>
</html>

Since both loggedIn.html and index.html use the same stylesheet, shouldn't they both be rendered in Georgia, Goudy, Sabon, or a serif font? 由于loggedIn.htmlindex.html使用相同的样式表,因此它们都不应该都以Georgia,Goudy,Sabon或Serif字体呈现吗? Apparently not. 显然不是。 The file structure is: 文件结构为:

┌ index.html
├ loggedIn.html
└ cgi-bin/
   └─────────── style.css

The file structure shouldn't be a problem either, since both .html files are in the same directory and use href="cgi-bin/style.css" . 文件结构也不应该成为问题,因为两个.html文件都位于同一目录中,并使用href="cgi-bin/style.css" I've never had a problem like this before. 我以前从未遇到过这样的问题。 Very strange! 很奇怪!

forgot your type. 忘了你的类型。 Also check the location of the css file. 还要检查css文件的位置。 I believe leaving out the type will cause problems. 我相信省略类型会导致问题。

<link rel='stylesheet' type='text/css' href='cgi-bin/style.css'/>

或者你可以做

<style type="text/css"> @import "cgi-bin/style.css"; </style>

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

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