0

I am learning web design and i have a very simple issue that i haven't been able to find an answer to. I created a very simple page for an example and both documents are in the same folder. it works as a snippet on here, but then it doesn't work on my computer. I have checked the filepath for the stylesheet several times, but it doesn't work. If anyone can help that would be very appreciated. Thanks! (im not sure if the snippet is useful but i thought i would include it anyways)

body {
  background-color: #eee;
}

#header {
  background-color: #66CCFF;
  color: white;
}
<div id="container">
  <div id="header">
    <h1>text</h1>
  </div>
  <div id="content">
    <div id="nav">
      <h3>nav</h3>
      <ul>
        <li>home</li>
        <li>about</li>
        <li>contact</li>
      </ul>
    </div>

    <div id="main">
      <h2> other text </h2>
    </div>
  </div>
</div>

2

2 Answers 2

1

This mainly has to do with the path of the file. Try this:

href="./style.css"

If that doesn't work show us the error you get

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

2 Comments

what you said worked. im really new so simple advice like this is really helpful. thank you
We were all in your shoes once. Accept the comment as answer and it should close the issue.
1

Just remember to follow this, to avoid again issue in case of accessing through parent directory:

parent folder:

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

same folder:

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

Comments

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.