Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Michael Matzner
12,651 Pointscant link html and css
I'm having trouble linking my css with all of my html files. Any advice or insight would be highly appreciated.
6 Answers
Michael Matzner
12,651 Points<!DOCTYPE html>
<html>
<head>
<title> POSH|HOME</title>
<link rel="stylesheet" href="poshhomework/css/main.css">
<link rel="stylesheet" href="poshhomework/css/responsive.css">
<meta name="viewport" content="width=device-width initial-scale=1.0">
</head>
<body>
<header class="main-header">
<span class="title">POSH|HOME</span>
<h1 class= "sub-header">Classic Style|Modern Sensibility</h1>
<nav>
<ul>
<li class="page"><a href="index.html">POSH|HOME</a></li>
<li class="page"><a href="about.html">ABOUT</a></li>
<li class="page"><a href= "photog.html">PHOTOGALLERY</a></li>
Jeff Kinley
21,207 PointsHi Michael,
You need to make sure that the links to your CSS file are correct. Here you are using relative; not absolute paths. Are you sure these are the correct paths to the file?
I believe if your html document is in the directory "poshhomework" and you have your CSS files in a "css" directory then the link in your CSS should probably be:
<link rel="stylesheet" href="/css/main.css">
<link rel="stylesheet" href="/css/responsive.css">
Where are you developing this? More info might help us figure it out.
Michael Matzner
12,651 Pointsive been using sublime text to write everything. I have a file folder on my desktop called "poshhomework" in the folder i have a "css" folder(with my css file) "html" folder(with all of my html files) an "img" folder(with all my img files). I tried what you recommended above and that took away all of my css styling on every page.
Jeff Kinley
21,207 PointsOk,
I'd probably move your html files out of the html folder and just leave them in the root directory, "poshhomework". This seems to be the typical way we organize our files.
Jeff
Michael Matzner
12,651 Pointsthanks for the insight. im not really sure what my issue is now. ive grouped both html and css in the poshhomework folder with no sub folder and now none of my css is working. Im using the free copy of sublime text 2 maybe that has something to do with it. my experience level is extremely novice but this issue is driving me mad.
Jeff Kinley
21,207 PointsI was assuming you would keep the css subdirectory, but remove the html subdirectory. Your file structure needs to look something like this:
poshhomework
- home.html
- about.html
- css
- main.css
- responsive.css
or, if you want to remove all subdirectories you need to change your links like this:
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="responsive.css">
because you have removed the css folder.
Michael Matzner
12,651 PointsJ thanks so much bro. i was over here driving myself insane. Thanks very much for the help. I really appreciate it.
Michael Matzner
12,651 PointsMichael Matzner
12,651 PointsThis code should be illustrated on every page of the website. However when I created my photogallery.html page and pasted this code. It didnt read any of the css at all. I'm very new to this whole process. So any advice would be great thanks. This is some of the css related to that code.