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.

HTML How to Make a Website Creating HTML Content Use the Navigation Element

davide totaro
davide totaro
5,559 Points

hi everyone, I have got a question, why we need to use in the head section before title, <meta charset="utf-8">

thanks in advance to everyone!!!!

2 Answers

Jeffrey Watters
PLUS
Jeffrey Watters
Courses Plus Student 7,403 Points

I began learning HTML in 1994. I was taught that the HTML document worked as if it were multiple switches. As an example you start by declaring what it is you are coding, which is HTML and so inside the code for the document you would place <HTML> tag, which includes all your other code. Then of course you don't leave a switch on when you leave a room so there is an ending switch at the end of the document.

Inside HTML there were three sections at the time (1994, this has changed over time) the HEAD (opening and closing tags), the body, and the Address (now called the footer as address now means something different and is coded differently as well). Each section communicated instructions for the browser for display purposes. So in the HEAD section you had the META DATA, such as a description, keywords, character code, and external files to apply to the document for formatting and user interaction such as a script. In the body section tags you place the information you want displayed on screen and the address section is now not used outside the body tag and has a different meaning.

The HEAD portion does not show directly on screen, it is translated and applied to the document and then used to assist with the display of your HTML elements within the body section. So only the body and address (now footer) would show on the users monitor being aided by the declarations within the HEAD section of the document.

So the reason why you put <meta charset="utf-8"> in the head is it is an instruction for display purposes which is telling the browser to use the utf-8 character set instead of some other character set. Of course utf-8 is the default but it still needs to be declared. See more: http://www.w3schools.com/tags/ref_charactersets.asp

I hope this helps.

Hi,

This specifies the character encoding for the HTML document (see w3schools for more info).

-Rich