0

I am baffled as to why this isn't working. Below is the reference to the css file in the head tag:

<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<head>
 <link rel="stylesheet" href="Candidate.css"/>
</head>
<body>

Here is a screen shot of the directory path and console output:

enter image description here

enter image description here

7
  • Candidate.css is in correct directory? based on error ur Candidate.css is locate at root folder? Commented Dec 6, 2018 at 2:55
  • I have tried changing the path to relative path and absolute paths and received the same error. It is strange. Commented Dec 6, 2018 at 3:04
  • Can you navigate the the CSS file directly from browser? Probably not related but the <script> tag should be either in the <head> or <body> tags. Where is the CSS file? Same directory as index? Or is it in a styles, css or similar folder? Commented Dec 6, 2018 at 3:11
  • Should have mentioned that the file: index is the file I have above showing the HTML script. The Candidate.css file is in the same directory as index. I wil try navigating directly to it. Commented Dec 6, 2018 at 3:21
  • The server you are using might need to be configured to allow the serving of css files. Try and enter a url to the css file directly into the browsers navbar. Commented Dec 6, 2018 at 3:45

1 Answer 1

1

Try getting the entire path to your file.

So if your using xampp your path might be:

C:\xampp\htdocs\website\css_folder_name\Candidate.css

However in practice your relative path is usually used so if your css file is in its own folder and your index.html is in the root directory where the folder for your css is you would type:

..\Candidate.css

The ..\ is a way of referencing the folder one level higher

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

2 Comments

I prefer using relative references when linking my styles because it becomes easier to move code around. That way if folder names change you do not need to go edit the path to contain the correct folder names
I would this problem with many of my website when I started learning HTML now I just use relative references always. It's also really convenient when you need to move your website from one domain to another because you do not need to change multiple lines of code.

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.