Jason Chong
Jason Chong

Reputation: 35

Why is my index.html not taking my style.css in my css folder?

I have this following file structure:

mysite/
├── css/
│   ├── style.css
│   
├── index.html

And my html code is:

    <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <link rel="stylesheet" href="css/style.css" type="text/css">
    <title>Home </title>
</head>

But when I run the site on the localhost (xampp), it is not taking the CSS. For as long as I know, I have been doing this all the time but its not working this time.

FYI: My Apache in xampp is indeed running.

Can anyone spot my mistake?

Upvotes: 1

Views: 879

Answers (3)

Gautam Naik
Gautam Naik

Reputation: 9358

try this,

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

I am assuming that you have a css folder and index.html file in your mysite folder.

In order to get the css file, you wil have to use above format, which tells index.html file to go to css folder and get style.css file

Upvotes: 1

Kearl
Kearl

Reputation: 86

Check the network tab inside the developer console and see if it indeed loads. Also, try doing

style.css?random=number

Dev console: F12 in FF, CTRL+SHIFT+I on chrome.

Upvotes: 0

SalahEddine Lahmam
SalahEddine Lahmam

Reputation: 1

try to put ../css/style.css to go back, your html file isn't in the same directory with the css one.

Upvotes: 0

Related Questions