0

別のファイルから .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>
4

2 に答える 2

3

タグlinkの形式が正しくないため、head(ドキュメントのルートではなく) 次の場所にある必要があります。

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

あるべきです(href=訂正に注意してください):

<link href="style.css" rel="stylesheet" type="text/css">
于 2013-02-15T15:22:39.797 に答える
0

これを試して

<link href="style.css" rel="stylesheet" type = "text/css">
于 2013-02-15T15:22:53.600 に答える