Home > Enterprise >  CSS file not linking to HTML file (same folder)
CSS file not linking to HTML file (same folder)

Time:03-13

I have this:

<head>
<title>1</title>
<link rel=“stylesheet” type="text/css" href=“style1.css”>
<script src="script.js"></script>
</head>

I've tried many things. removing the type, adding a / at the end, adding a ./ before style1.css, etc. Both the html file and the css file are in the same folder. The html works. here is the css:

p {
    color: red;
}

h1 {
    color:blue;
}

where did I go wrong ?

CodePudding user response:

check your quotations around your attribute value, just replace your link with below, and hopefully, this should work:

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

CodePudding user response:

It seem you are using wrong double quotes symbol in the link tag

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

It should be

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

CodePudding user response:

p {
    color: red;
}

h1 {
    color:blue;
}
<!DOCTYPE html>
<html lang="en">
<head>
        <title>1</title>
        <link rel="stylesheet" type="text/css" href="style1.css">
        <script src="script.js"></script>
        </head>
<body>
    <p>this is paragraph</p>
    <h1>this is h1 heading</p>
</body>
</html>

your reference to the stylesheet look like this

  • Related