Reputation: 11
I am having an issue with getting my css file to link up to my html code when I put my css file in a different folder than the one my html file is in. I have tried to research how to enter the correct file path for my css file but it still doesnt seem to work. It does work though when the css file is in the same folder as my html file. Here is how I am have gotten the code to work correctly:
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Connor Rice</title>
<link rel="stylesheet" type="text/css" href="Together-1.css"/>
</head>
<body>
The code goes on for longer but I dont think it has anything to do with the stuff after. This is where my HTML File is:
/Users/connorrice/Desktop/CodingStuff/HTML Class Stuff/ConnorRice.html
My CSS file is here:
/Users/connorrice/Desktop/CodingStuff/HTML Class Stuff/Together-1.css
I'm trying to change the html code to this
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Connor Rice</title>
<link rel="stylesheet" type="text/css" href="CSS-Files/Together-1.css"/>
</head>
<body>
Here's where I moved the file css file to (HTML one is in the same place)
/Users/connorrice/Desktop/CodingStuff/CSS-Files/Together-1.css
Think I typed the correct syntax in but its not working. I'm using mac 0s sierra version 10.12.6 on a macbook pro that came out in 2011 (I know my computer is really old). Any suggestions as to what I'm doing wrong? Also please forgive me if I typed this out horribly because this is the first question I've posted and I'm very new to coding.
Upvotes: 0
Views: 115
Reputation: 26
To access the folder you placed your CSS in, your stylesheet href should be:
href="../CSS-Files/Together-1.css"
The way you wrote it, you are trying to look for the CSS-Files folder in your HTML Class Stuff folder. However, you must first exit the HTML folder.
That is what you use ../
for, at the start of your path.
Upvotes: 1