Vedantkarandikar
Vedantkarandikar

Reputation: 51

How to access root directory in html?

I am just beginning HTML and I wanted to know how to use root directory in HTML?

I have a css and js folder in the root directory and I linked it(using relative URL) for the index.html in that directory. But now I have a subdirectory called foo along with the css and js sub-directory's. Now in the foo folder I cannot use relative URL because the css folder is not in that directory.

Do I have to use absolute URL, or is there a way to use /code_for_main_dir/css

Upvotes: 1

Views: 5834

Answers (2)

Warf
Warf

Reputation: 311

Path starting with / means root directory.

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

More info: https://www.w3schools.com/html/html_filepaths.asp

Upvotes: 2

Vedantkarandikar
Vedantkarandikar

Reputation: 51

As @thesilkworm said,

using ..goes one directory up.

But, using / goes to the root of that web.

so, /css instead of css

Upvotes: 1

Related Questions