IntelliJ CSS not connecting to HTML

I keep getting this error message in IntelliJ “Failed to load resource: the server responded with a status of 404 (Not Found)” not sure why.

Also, when I edit in CSS, it does not show in the Preview or Live edit session. I don’t think it’s connecting to the HTML file and not sure why. Like the CSS code isnt affecting the html file and not showing when I run it.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

    <div>
        <p>tester</p>
    </div>

</body>
</html>
body
{
    background-color: yellow;
}
.p
{
    color: blue;
}

Where do you load the CSS into your DOM?

You need at minimum something like:

<head>
<link rel="stylesheet" href="mystyle.css">
</head>
1 Like

I forgot that! Thank you!! But how come that’s needed if the css is under the same file as html?

What do you mean with “Under the same file”?

This selector is targeting an element with a class of p, not the p element itself.
So it will target this:-

<div class="p">

But to target this:-

<p>tester</p>

You use:-

p {
    color: blue;
}

like under the same main project file. for example, ProjectTester folder has style.css and index.html under it.

Oh thank you. Sorry didn’t actually mean to put that .p in there in this example. in my actual file it’s the p element tag not class.

Even if Intelliji could be intelligent enough to find the css file in the Same folder, it would not really help you. Because when you deploy your webpage to a standard Apache, Apache will not have such a feature.

So you have to take care that the files you need are included no matter where they are located

1 Like

Oh I see. Thank you so much!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.