CSS

Clay McDermott
Clay McDermott
1,378 Points

linking css to html in visual studio

Hello, I am trying to link css to html in my first project in visual studio, and it won't link. I have watched every you tube tutorial and made more pages different ways to try to link them. Is there something wrong with my code? The file path is copied directly.

<!DOCTYPE HTML> <html lang="en">

<head> <title>Clay McDermott, Web Developer </title> <link href="C:\Users\clayton.mcdermott\Desktop\CSS.css" rel="stylesheet" type="text/css">

<h1> CAPTAIN CLAY MCDERMOTT, WEB DEVELOPER </h1>

Hello Clay, as I see from your file path you're using the Desktop directory as a project folder which isn't a good practice. Inside the Desktop directory, try to create a folder, and call it, for example, web-developer, and then create an "index.html" file and a "style.css" file, and now you use this tag to link them together: <link rel="stylesheet" type="text/css" href="style.css"

Good luck!

2 Answers

Brandon White
seal-mask
MOD
.a{fill-rule:evenodd;}techdegree seal-36
Brandon White
Treehouse Moderator

Hi Clay,

El Mehdi is absolutely correct with the advice offered. That shouldn’t be the reason that the file doesn’t open correctly on your local machine (although if you used that same file path on a deployed site it would not work). I’m thinking the issue is probably that the browser is not able to find your file, and my guess would be to take a look at the clayton.mcdermott directory in the Users directory as it’s a bit strange to see a dot in a directory name. Make sure that file path is spelled correctly (as good practice for debugging filepath issues if you’d like).

But piggybacking off of El Mehdi, it’s good practice to create a project folder for each coding project and to store all of your files there.

Clay McDermott
Clay McDermott
1,378 Points

Thank you both for the excellent feedback I will work in getting the files into a project folder and hopefully that works.