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

CSS

Unable to link my css stylesheet to html file.

Trying to code my first html document from scratch and link an external stylesheet to it. After 2 hours of not being able to get it working I am asking you guys. What am I doing wrong?

My html file:

<!DOCTYPE html>

<html> <head> <title>My HTML Shack</title <link rel="stylesheet" type="text/css" href="css/style.css"> </head>

<Body> <header> <h1>My HTML shack</h1> <nav> <ul> <li>Home</li> <li>Products</li> <li>About Us</li> </ul> </nav> </header>

<img src="img/office.jpg" alt="Office Space" height="200" width="300">

<p>This is a paragraph</p> </body>

</html>

My css file:

header { background-color: blue; }

p { font-size: 72px; color: blue; }

I have organized the files in a folder called test with subfolders: css and img. The html file is in the test folder.

Does anyone see what I am doing wrong?

Regards Terjemk

2 Answers

Sam Gord
Sam Gord
14,084 Points

hey there, i spotted the problem , you have missed the closing " > " for your <title> tag, and also, the body tag should be written like this --> <body></body>, no capitals! :D

<!DOCTYPE html>

<html> 
<head> 
<title>My HTML Shack</title> 
<link rel="stylesheet" type="text/css" href="css/style.css"> 
</head>

<body> 
<header>
 <h1>My HTML shack</h1> 
<nav> 
<ul> <li>Home</li> <li>Products</li> <li>About Us</li> </ul> 
</nav> 
</header>

<img src="img/office.jpg" alt="Office Space" height="200" width="300">

<p>This is a paragraph</p> 

</body>
</html>

Thank you so much Sam!

I guess it takes some time to be good at debugging the syntax:)

Have a great day!

T

Sam Gord
Sam Gord
14,084 Points

you'll be good at this sooner than u expect . have a great day you too ;)