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

HTML How to Make a Website CSS: Cascading Style Sheets Use ID Selectors

Nyakeh Konneh
Nyakeh Konneh
1,321 Points

Linking not working or am i doing something wrong?

I am currently trying to do exactly what you just did but on a different text editor. it's not working. i am using the same css files i downloaded for the follow along but when i saved them and link them the html i have created, it doesn't work. Why?

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,252 Points

Hi there,

Could you post your code for us as it is so we can have a look at it for you? Thanks. :)

Hi Nyakeh,

Please post your code so we can take a look.

-Rich

Nyakeh Konneh
Nyakeh Konneh
1,321 Points

This is my html file. <!DOCTYPE html> <html>

<head> <title>My First HTML</title> <meta charset="UTF-8"> <link rel="stylesheet" href="css/normalize.css"> <link rel="stylesheet" href="css/main.css"> </head>

<body> <h1>Ride Along</h1> <h2>Ice Cube, Kevin Hart</h2> <p>Lionel Messi?</p>

</body> </html>

And the css file h1 { background-color: orange; }

3 Answers

Ben Chadwick
Ben Chadwick
4,836 Points

Hi Nyakeh,

As a starting point its a good idea to continue to use the <head> and <body> tags when starting html. Although not necessary it gives you an understanding of how the mark-up needs to be structured.

If you are linking to an external style sheet the link must be present in the <head> section of the HTML.

For example if your CSS file is called main.css and is inside a css folder in your directory it would look like this

<DOCTYPE! html>
<html>
   <head>
      <title>My First HTML</title>
      <link rel="stylesheet" href="css/main.css">
   </head>

   <body>
       <h1>Ride Along</h1>
       <h2>Ice Cube, Kevin Hart</h2>
            <p>Lionel Messi?</p>
   </body>
</hmtl>

Hope this helps

Ben Chadwick
Ben Chadwick
4,836 Points

should be !DOCTYPE my bad

Ben Chadwick
Ben Chadwick
4,836 Points

should be !DOCTYPE my bad

Nyakeh Konneh
Nyakeh Konneh
1,321 Points

Thanks. That worked. I saved the css file in the same folder as my html file. Now i am trying to figure out how to link the css file if i saved it in a different folder. But this is how i got it to work the first time <!DOCTYPE html> <html>

<head> <title>My First page</title> <link rel="stylesheet" type="text/css" href="style.css"> </head>

<body> <h1>The Family</h1> <h2>We are riding along to achieve our goal </h2> <p>Hey what's up?</p>

<div id="main">Setting the width of a block element will prevent it from stretching out to the edges of it's container to the left or right. Then, you can set the left and right margins to auto to horizontally center that element within its container. The element will take up the width you specify, then the remaining space will be split evenly between the two margins.
</div>

<div class="simple">I'm smaller</div>
<div class="fancy">And I'm bigger</div>
<div class="static">static is the default value. An element with position: static; is not positioned in any special way. A static element is said to be not positioned and an element with its position set to anything else is said to be positioned.
</div>

</body> </html>

note: so now i wanna link it from a different folder.