Goro
Goro

Reputation: 499

Css doesn't work properly when is in other folder

I've using bootstrap and file and folders is like this

root/css/..

When I include <link id="bs-css" href="css/bootstrap.min.css" rel="stylesheet"> it is working for files in root folder. But if I have file in another folder and trying to include css doesn't work. It doesn't show any style. For example

root/users/profile.php

then I include in profile.php like this

<link id="bs-css" href="../css/bootstrap.min.css" rel="stylesheet">

I've also tryed full path again didn't work properly. But if I put inside /users/ css file or full folder is working href="css/bootstrap.min.css"

Upvotes: 0

Views: 3867

Answers (3)

Omar Ali
Omar Ali

Reputation: 11

add just slash before "css" folder. ex: href="/css/bootstrap.min.css"

Upvotes: 0

Ricky Goldman
Ricky Goldman

Reputation: 349

Try using href="/css/bootstrap.min.css" This should work no matter where your php or html file is located. This is called a relative path. So..

<link id="bs-css" href="/css/bootstrap.min.css" rel="stylesheet">

As long as css is a direct child of the root, this should find it.

Upvotes: 1

Jase Pellerin
Jase Pellerin

Reputation: 397

You can change the link to be the full path from your URL like this:

<link id="bs-css" href="yoursite.com/css/bootstrap.min.css" rel="stylesheet">

That should work from any page.

Upvotes: 2

Related Questions