0

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.

1
  • <link rel="stylesheet" type="text/css" href="http://your-domain/CSS-Files/Together-1.css"/> the setting will load okay Commented Sep 30, 2018 at 23:15

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks so much that worked! Is the .. a convention that always means go up one folder? Or do you need to add more dots if you are going up another level?
Yes, that is a convention to go up one folder. If you needed to go up two levels you would type "../../" and so on
You can find all path computing rules here. Web uses Unix (first in table).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.