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 Creating HTML Content Include External CSS

Harshay Raipancholi
seal-mask
.a{fill-rule:evenodd;}techdegree
Harshay Raipancholi
Python Development Techdegree Student 11,521 Points

I have added the tag <link rel="stylesheet" ...> but for some reason when i preview the site the style does not apply!

The linked normalize.css does not work , can you please assist, my code is below :

<!DOCTYPE html> <html>
<head>
<meta charset="utf-8"> <title>Harshay | Designer</title>
<link rel="stylesheet" href="css/normalize.css"> </head> <body> <header> <a href="index.html"> <h1>Harshay Raipancholi</h1> <h2>Data Scientist</h2> </a> <nav> <ul> <li><a href="index.html">Portfolio</a></li> <li><a href="about.html">About</a></li> <li><a href="contact.html">Contact</a></li> </ul> </nav> </header> <section> <ul> <li> <a href="img/numbers-01.jpg"> <img src="img/numbers-01.jpg" alt=""> <p>Experimentation with Color and Texture.</p> </a> </li> <li> <a href="img/numbers-02.jpg"> <img src="img/numbers-02.jpg" alt=""> <p>Playing with blending modes in Photoshop.</p> </a> </li> <li> <a href="img/numbers-06.jpg"> <img src="img/numbers-06.jpg" alt=""> <p>Trying to create an 80's style of glows.</p> </a> </li> <li> <a href="img/numbers-09.jpg"> <img src="img/numbers-09.jpg" alt=""> <p>Drips created using Photoshop Brushes.</p> </a> </li> <li> <a href="img/numbers-12.jpg"> <img src="img/numbers-12.jpg" alt=""> <p>Creating shapes using Repetition.</p> </a> </li> </ul> </section> <footer> <a href="http://twitter.com/harshayr"><img src="img/twitter-wrap.png" alt="Twitter Logo"></a> <a href="http://facebook.com/harshaykr"><img src="img/facebook-wrap.png" alt="Facebook Logo"></a> <p>© 2014 Harshay Raipancholi.</p> </footer>
</body> </html>

It's seems that the tags

<html> , <head> and <body>

are missing in your code..

As the following lines are not inside the

tag, your code will not find your css file.

  <meta charset="utf-8">
  <title>Harshay | Designer</title>      
  <link rel="stylesheet" href="css/normalize.css">

And don't forget the " type " attribute in the link to css file, i'm not sure if this really affects the code, but it's a good idea for semantics purpose.

hope that helps ;D

Guilherme is correct. I just want to explain a bit more. The <html>, <head>, and <body> elements are all necessary elements. The <html> element tells the browser that it is working with an HTML file. This is a necessary tag. The <head> portion of the HTML document is where styles, meta data, your title, etc. are specified. The <body> portion of the HTML document is where all of the content that a user sees is specified.

Also, the type = 'text/css' declaration is no longer used in HTML5 but is required if you are using HTML4. The only value for type is text/css, so my guess is that there was an expansion planned for using type that was never implemented.

6 Answers

Harshay Raipancholi
seal-mask
.a{fill-rule:evenodd;}techdegree
Harshay Raipancholi
Python Development Techdegree Student 11,521 Points

Thanks for the reply guys, it still doesn't seem to work , updated code is below , <head> tag and type is added :

<!DOCTYPE html> <html>
<head>
<meta charset="utf-8"> <title>Harshay | Data Scientist</title>
<link rel="stylesheet" href="normalize.css" type="text/css"> </head> <body> <header> <a href="index.html"> <h1>Harshay Raipancholi</h1> <h2>Data Scientist</h2> </a> <nav> <ul> <li><a href="index.html">Portfolio</a></li> <li><a href="about.html">About</a></li> <li><a href="contact.html">Contact</a></li> </ul> </nav> </header> <section> <ul> <li> <a href="img/numbers-01.jpg"> <img src="img/numbers-01.jpg" alt=""> <p>Experimentation with Color and Texture.</p> </a> </li> <li> <a href="img/numbers-02.jpg"> <img src="img/numbers-02.jpg" alt=""> <p>Playing with blending modes in Photoshop.</p> </a> </li> <li> <a href="img/numbers-06.jpg"> <img src="img/numbers-06.jpg" alt=""> <p>Trying to create an 80's style of glows.</p> </a> </li> <li> <a href="img/numbers-09.jpg"> <img src="img/numbers-09.jpg" alt=""> <p>Drips created using Photoshop Brushes.</p> </a> </li> <li> <a href="img/numbers-12.jpg"> <img src="img/numbers-12.jpg" alt=""> <p>Creating shapes using Repetition.</p> </a> </li> </ul> </section> <footer> <a href="http://twitter.com/harshayr"><img src="img/twitter-wrap.png" alt="Twitter Logo"></a> <a href="http://facebook.com/harshaykr"><img src="img/facebook-wrap.png" alt="Facebook Logo"></a> <p>© 2014 Harshay Raipancholi.</p> </footer>
</body> </html>

The type declaration can be completely omitted. The problem is that your code is missing the <html>, <head>, and <body> elements from the page. Your page should look like this (notice what is different):

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
  <title>Harshay | Data Scientist</title>      
  <link rel="stylesheet" href="normalize.css" type="text/css">
</head>

<body>
  <header>
     <a href="index.html">
        <h1>Harshay Raipancholi</h1> 
        <h2>Data Scientist</h2>
     </a>
     <nav>
        <ul>
           <li><a href="index.html">Portfolio</a></li>
           <li><a href="about.html">About</a></li>
           <li><a href="contact.html">Contact</a></li>
        </ul>
     </nav>
  </header>
  <section>
     <ul>
        <li>
           <a href="img/numbers-01.jpg">
              <img src="img/numbers-01.jpg" alt="">
              <p>Experimentation with Color and Texture.</p>
           </a>
        </li>
        <li>
           <a href="img/numbers-02.jpg">
              <img src="img/numbers-02.jpg" alt="">
              <p>Playing with blending modes in Photoshop.</p>
           </a>
        </li> 
        <li>
           <a href="img/numbers-06.jpg">
              <img src="img/numbers-06.jpg" alt="">
              <p>Trying to create an 80's style of glows.</p>
           </a>
        </li> 
        <li>
           <a href="img/numbers-09.jpg">
              <img src="img/numbers-09.jpg" alt="">
              <p>Drips created using Photoshop Brushes.</p>
           </a>
        </li> 
        <li>
           <a href="img/numbers-12.jpg">
              <img src="img/numbers-12.jpg" alt="">
              <p>Creating shapes using Repetition.</p>
           </a>
        </li> 
     </ul>
  </section>
  <footer>
     <a href="http://twitter.com/harshayr"><img src="img/twitter-wrap.png" alt="Twitter Logo"></a>
     <a href="http://facebook.com/harshaykr"><img src="img/facebook-wrap.png" alt="Facebook Logo"></a>
     <p>&copy; 2014 Harshay Raipancholi.</p>
  </footer>      
</body>
</html>
Harshay Raipancholi
seal-mask
.a{fill-rule:evenodd;}techdegree
Harshay Raipancholi
Python Development Techdegree Student 11,521 Points

Thanks for your reply marcus, my code does include <html>, <head>, and <body> elements for some reason these havent appeared in my post , it still does not apply the styling !

When you are copying and pasting code into the forums, it is very important that you do the following:

  • Make sure the opening and closing 3 ` marks are on their own separate line.
  • Make sure that there is a blank line above the opening 3 ` marks (and a blank line below the last three marks if you are planning on adding text after the code block)

So, when you are formatting your answer and you haven't submitted it yet, it should look like this (with ` instead of ' of course):

'''

//PASTE CODE HERE

'''

You can also add a specific language to the code block so that it is highlighted better, such as if you are pasting HTML code, you can do the following:

'''html

//PASTE CODE HERE

'''

Well, as it seems that you are doing the "How to make a website with html and css" course. i think that there's more things that you forgot. In this project is necessary to include the path in wich the normalize.css file is stored.

<link rel="stylesheet" type="text/css" href="css/normalize.css">
John Burkhard
John Burkhard
16,314 Points

Cut and paste the contents of your file to pastebin.com so we can see what the file actually has in it. How is your directory structure setup? Is your CSS file in a subfolder labeled "css"? If so you're not targeting the file properly in your last post (you omitted the path to the directory).

John Burkhard
John Burkhard
16,314 Points

Is the file normalize.css spelled correctly?

Can you post a screenshot of your workspace?

Is there any content inside of normalize.css? Paste the contents of normalize.css please.