1

I have a website where I am referencing the CSS/JS in the root directory. I want to create a sub-section of the website under it's own directory. The problem is that I am referencing the CSS/JS in the main directory and I want to know what the best way to reference the CSS/JS would be for the subdirectory.

If I just use the http address for the files it works, but I think there could be a better way to go about this. Does anyone have any opinion on the matter?

1

1 Answer 1

2

You can use ../ to specify the parent directory when using relative paths. So for example, if your file structure is something like this:

root
    index.html
    style.css
    javascript.js
    subdirectory
        subpage.html

Then in your subpage.html file, use:

<link rel="stylesheet" href="../style.css">
<script src="../javascript.js"></script>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.