How to Link a CSS File from HTML File

Linking CSS File with HTML Document In Different Directories On my Windows

You should go back one directory back by ../. This way go to parent folder of these two files. Then start to go into css file's directory.

href="../styles/style1.css"

Link CSS from another folder?

If your current folder is /current/folder/location/index.html, and your .css file is in /current/second/folder/style.css, then use this as an example:

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

or alternatively:

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

However, if the second file is in `/current/folder/second/style.css, then use:

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


Related Topics



Leave a reply



Submit