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 HTML First Use HTML Elements

Shavon Bilis
Shavon Bilis
403 Points

How do I add head and body elements to a page?

I'm having trouble with Challenge task 3 of 6. It's asking me to add the head and body elements to the page.

I had the same issue. I first put:

```<!DOCTYPE html> <html></html> <head></head> <body></body>

, since I had the first two lines from tasks 1 and 2, I thought to just add ```<head>``` and ```<body>``` tags to the next lines.

However, the correct answer is :

```<!DOCTYPE html>
<html>
<head></head>
<body></body>
</html>

You have to move the </html> end tag to the end because all the content in the middle (head, body) is still part of HTML.

P.S. If you want to quote your code, you put 3 ` signs before and after your code. It's the button right above tab on the left of the keyboard.

2 Answers

I would suggest going back through the video as Nick gives a great explanation.

!DOCTYPE html tells the browser what document type it is.

html will encompass your entire document. So the closing tag will be the very last item on the document so the browser knows that that is the end of your html code.

head will be the next set of tags. This will include the meta charset to tell the browser what character set you are using. It will also include your title tags which will set the name you can find on the browser tab.
Later on, you will learn about adding the CSS link and fonts under the title tag.

Finally, you have your body tags which will include all of the content on your web page.

Hope this helps! =]

Michael Hulet
Michael Hulet
47,912 Points

You nest them inside of the <html></html> element. This code passes the entire challenge:

<!DOCTYPE html>
<html>
  <!-- This is the head element -->
  <head>
    <meta charset="utf-8"/>
    <title>Page Title</title>
  </head>
  <!-- This is the body element -->
  <body>
    <header>
    </header>
    <section>
    </section>
    <footer>
    </footer>
  </body>
</html>