Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My CSS is not being applied to my html, how do i fix it?

Tags:

html

css

So i have this weird problem that any css i write doesn't work. I tried to create multiple pages and link css but it simply doesn't apply. If i download a template of the internet if i run the page, their html works.

Here is an example of the most basic code i've written that doesn't work, even though i've run it through validators. It doesn't matter what element im trying to apply styling to it doesn't work.

HTML

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title> Test Page </title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <h1> Sup! </h1>
</body>
</html>

CSS

body {
    font-size: 16px;
    color: #fff;
    background-color: #61122f;
}

I have tried numerous solutions i've found online, but none of them work.

like image 598
Vexane Avatar asked Oct 16 '25 02:10

Vexane


2 Answers

I had a similar issue, I believe the problem was coming from the name of my CSS folder in which I had the CSS file. The folder was named "CSS", I'm not sure why it was causing issues but when I put my css file into my "js" folder it worked perfectly fine. Then I created a new folder named "myCSS" and it worked still. This is a weird workaround but it solved my issue and it may be useful to someone else.

also for the link I just had <link rel="stylesheet" href="myCSS/style.css" />

like image 98
DaltonR Avatar answered Oct 18 '25 19:10

DaltonR


Can you check your network tab that your style.css is fetched from server and there is no 404 not found.

I would say try "/styles.css"

like image 36
icebug Avatar answered Oct 18 '25 20:10

icebug



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!