How to Link HTML Pages in Same or Different Folders

Linking HTML and CSS that are in different folders

It looks like this is what you need:

SITE
|
+--- HTML
| |
| +--- index.html
+--- CSS
|
+--- main.css

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

First you navigate out of your current folder ("..") and then into your CSS folder.

How do I link files from different folders in HTML?

Using ../ allows you to jump back a directory (folder) and ../../ would jump back two directories. If your at the root directory you can access a file with /index.html. Have a look at the Dealing with files - MDN documentation for more detailed information.



Related Topics



Leave a reply



Submit