简体   繁体   中英

Linking CSS file and HTML/PHP files from different folders

Hello i have a question about HTML and CSS linking. My problem is that I have HTML files in HTML_folders and CSS files in CSS_folders i want to link my CSS to my HTML but it wont display in explorer. I have linked it as <link rel="stylesheet" type="text/css" href="CSS/index.css"> but no display what did I do wrong?

If you have two folders which are siblings (both on the same level in the folder structure) like this:

main folder
  |__ HTML
  |__ CSS

then to traverse from one to the other you first need to go up and level to the parent and then back down to the CSS folder.

The way you've got it at the moment it's trying to point to a CSS folder below the HTML folder (ie a subfolder of it).

This should work for you (assuming the folder is definitely called CSS ):

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

The .. is what indicates going up one level.


NB A more conventional design is usually to have the HTML in a main folder and the CSS in a subfolder (and Javascript in a second subfolder).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM