Reputation: 55
So I'm starting to dig into web development again and I thought I would just cover the absolute basics to start with. For whatever reason my stylesheet isn't linking and I've done, what I believe, is how you properly approach this. If I have all of the files inside of just the main project directory it links properly and works, but I have a structure like this: Project/resources/css(css files), html(html files), javascript(js files) and a link like this to the css file:
<link rel="stylesheet" type="text/css" href="/resources/css/styles.css">
But this won't work at all for some reason. If I structure the project like this: Project/index.html, styles.css, script.js , it will work when I link it like so:
<link rel="stylesheet" type="text/css" href="styles.css">
I thought I was linking it properly so it's not making much sense to me. Any help would be appreciated! Note: I have looked through other Stack overflow posts where people had the same issue which is why I thought the way I linked the file was correct
Upvotes: 0
Views: 116
Reputation: 340
Use full URL: http://yourwebsite.com/resources/css/styles.css Otherwise, check if you are in root folder (in browser) eg. localhost/folder/index.html in this case, the initial '/' in your link will point to folder/resources, not resources as root
Upvotes: 2
Reputation: 34
So in order to go to a parent directory, You would do the ../css/styles.css
Hope that helps.
Upvotes: 1