Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS CSS Foundations Getting Started with CSS Adding CSS to a Page

Solved - I can't link an external CSS to the index.html

Stage 1: Getting started with CSS. I wrote the code in Sublime 2 just like in the video for both index.html and style.css. I have a folder on my desktop called "adding-css". Inside the folder there is the index.html and another folder called "css", where the "style.css" is located.

<!DOCTYPE html>
<html>
<head>
    <title>Adding CSS</title>
    <link rel="stylesheet" href="css/style.css">
    <style type="text/css">
    h1 {
        color: white;
        background-color: #E14607;
    }
    </style>
</head>
<body style="background-color: #BDD4DE;">
    <h1>Adding CSS to the Page</h1>
    <p style="font-weight: bold;">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.</p>
    <h2>Lorem ipsum dolor sit amet</h2>
    <ul>
        <li>Duis aute irure dolor</li>
        <li>Nemo enim ipsam voluptatem</li>
        <li>Ut enim ad minim veniam</li>
        <li>ed quia consequuntur magni</li>
    </ul>
</body>
</html>

css:

h2 {
    color: steelblue;
    padding-bottom: 10px;
    border-bottom: 2px dotted;
}

ul {
    color: white;
    background-color: steelblue;

}

Is it something wrong with the path or why is it not working? Please help. Workspaces was much easier than Sublime...

3 Answers

Nevermind, I found the answer. My index.html was originally saved on desktop in Sublime and not inside the "adding-css" folder. I saved it again in the right location and now it works :)

The code itself seems fine to me. I just saved them both on my computer and ran them, and it works! I would suggest that you look more closely at the file names and paths, and make sure they are correct. For example the style.css file should be saved as a css file, not a style.css plain text file.

I hope this helps.

Nevermind! Glad to see you solved your problem! :)

Thank you! :)