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 CSS Foundations Getting Started with CSS Adding CSS to a Page

My styles won't apply when I refresh my page in the browser.

I'm going through the exercise Getting Started with CSS, and I'm doing the part where I'm supposed style the paragraphs and header with inline styles, which works perfectly. But when I want to style them externally in the styles.css file and refresh the browser, it doesn't work.

It's as if the browser only recognizes the index.html and not the styles.css. I'v already tried redownloading the exercise files and nothing changes.

5 Answers

Romain Gaget
Romain Gaget
24,449 Points

Are you sure you linked you css file correctly at the top of you html?

Yes, here I have the rel attribute along with everything else to communicate the files.

<html>
<head>
    <title>Adding CSS</title>
    <link rel="stlyesheet" href="css/style.css">
</head> 
<body style="background-color: #BDD4DE;">
    <h1>Adding CSS to the Page!</h1>
    <p style="font-weight: bold;">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> 

Nothing. The exercise says css/style.css, so theres no changing it. I tried it, but it didn't do anything.

Romain Gaget
Romain Gaget
24,449 Points

try "stylesheet" href="css/style.css"(you misspelled stylesheet)

I corrected the spelling on stylesheet. Now what.

Try

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

In the head of your index.html file Best regards

The href is pointing to the wrong file location. Find styles.css in the folder and right click>Properties> and copy the location of the file.

For example my location is C:\Users\tom\Desktop\Treehouse\getting-started-with-css (1)\adding-css-to-page\start\style.css

My link looks like this:

<link rel="stylesheet" href="C:\Users\tom\Desktop\Treehouse\getting-started-with-css (1)\adding-css-to-page\start\styles.css">