htmlcssfilefile-link

CSS file linking issue


Why is my CSS file not linked when the HTML file is inside a folder within the folder that contains both folders? I tried deleting the main folder address from the link and it still persists.

https://i.sstatic.net/Q1mWA.jpg

*The CSS file is OK and works only when the HTML file is not in a separate folder.


Solution

  • If you want to use the relative path to the CSS file, then the link href needs to be relative to your html file:

    <link rel="stylesheet" href="../css/9a.css">

    The .. indicates that you want to navigate outside the "html" folder where your html file is located, then find the "css" folder, then find your css file.