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

linking style sheet to html

I have followed the video exactly when creating a html document index.html saved to my desktop>css (because that is the lesson). In the same folder, I have style.css. I have linked the stylesheet in my html file right below the <title> as <link rel="stylesheet" href="css/style.css">. No matter what I do, the css code will not apply to my html page.

7 Answers

Christian Frick
Christian Frick
14,584 Points

Try this:

<link rel="stylesheet" type="text/css"  href="style.css">

<pre> <!DOCTYPE html> <html> <head> <title>Adding CSS</title> <link rel="stylesheet" type="text/css" href="css/style.css"> </head> <body> <h1>Adding CSS to the Page!</h1> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum non diam justo. Integer accumsan lacus ut quam pulvinar ullamcorper. Proin imperdiet mauris ac lectus blandit adipiscing. Vestibulum placerat mi sit amet odio luctus quis aliquam ante tristique. Praesent sem ligula, rhoncus quis gravida vitae, consequat id odio.</p> <p>Etiam eros nisl, pretium nec suscipit ac, gravida quis velit. Phasellus adipiscing ultrices lorem, ut porttitor tellus interdum eu. Fusce auctor, felis vitae adipiscing vulputate, tellus odio venenatis lorem, et pretium lectus justo vitae ipsum. Mauris in dictum dolor. Sed fermentum, dolor nec mollis lobortis, eros augue laoreet tortor, vel cursus neque sem ac diam.</p> <h2>Lorem ipsum dolor sit amet</h2> <ul> <li>Praesent sem ligula rhoncus</li> <li>Donec ut ipsum at quam</li> <li>Maecenas libero neque accumsan ut</li> <li>Donec quis mauris ipsum</li> </ul> </body> </html> </pre>

Christian Frick
Christian Frick
14,584 Points

Please use the Markdown Cheatsheet

Grant Novey
Grant Novey
10,352 Points

If you can post your code, we can take a look at it for ya' and help out.

            <p>This is code!</p>
            ``` 


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

ul {
    color: #FFF;
    background-color: steelblue;
}
            <p>sorry I'm new at this forum</p>
            ``` <!DOCTYPE html>
<html>
<head>
    <title>Adding CSS</title>
    <link rel="stylesheet" href="css/style.css">
</head>
<body>
    <h1>Adding CSS to the Page!</h1>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum non diam justo. Integer accumsan lacus ut quam pulvinar ullamcorper. Proin imperdiet mauris ac lectus blandit adipiscing. Vestibulum placerat mi sit amet odio luctus quis aliquam ante tristique. Praesent sem ligula, rhoncus quis gravida vitae, consequat id odio.</p>
    <p>Etiam eros nisl, pretium nec suscipit ac, gravida quis velit. Phasellus adipiscing ultrices lorem, ut porttitor tellus interdum eu. Fusce auctor, felis vitae adipiscing vulputate, tellus odio venenatis lorem, et pretium lectus justo vitae ipsum. Mauris in dictum dolor. Sed fermentum, dolor nec mollis lobortis, eros augue laoreet tortor, vel cursus neque sem ac diam.</p>
    <h2>Lorem ipsum dolor sit amet</h2>
    <ul>
        <li>Praesent sem ligula rhoncus</li>
        <li>Donec ut ipsum at quam</li>
        <li>Maecenas libero neque accumsan ut</li>
        <li>Donec quis mauris ipsum</li>
    </ul>
</body>
</html>

Thank you! , removing the /css and adding type="text/css" worked beautifully! wonder why this isn't in the video.... :-)