Helps needed on Part 1 5/9 The head

Hey, friendly folks out there

I just started CODEACDEMY today and got stuck on the Part 1, 5/9:The head

The sys actually allows me to go to 6/9, however, after adding the code that I pasted below, I don’t see any changes on the interface, the right screen.

<!DOCTYPE html>
   <title>My Coding Diary</title>

Please help!

Thank you kindly!

You won’t see any change since the interface is embedded in Codecademy’s site, and it is their title bar we see on browser tab. If you copy the code to your own machine (paste into a text editor and save with .html extension somewhere sensible) then open the file in a browser you will see your title on the browser tab.

It’s vital that you recognize the importance of the title element in a web document. It is what Search Engines use for the link text in a search results page. They also compare it to the highest level heading, but you’ll get to that so I won’t ruin it for you. Just know this element is very important. It is only written in the HEAD section and should be very near the top, just under the <head> opentag.

This may be jumping ahead, a wee bit, but I’m going to toss it in for future reference:

<!DOCTYPE html>
<html lang="en">
  <meta charset="UTF-8">
  <title>The title follows the character encoding declaration</title>

You’ll get to the <body></body> section in the next lesson so I left it out. Above we have,

  1. A document type declaration that tells the user agent (browser, search engine, etc.) that the root element of this web document is <html></html>. That is where the HTML starts and is contained. A doctype is not an HTML element. It’s just a special header in the absence of which the browser may or may not know how to render the document correctly. The simplest form if the above, and it tells the browser to parse this page as HTML5.
  2. A root element, as mentioned above. The human readable language is English.
  3. A head element that contains metadata
  4. A character encoding declaration. UTF-8 is the standard for most web documents.
  5. A title element to tell readers what the page is about. This element should never have more than 64 characters and should always be very near the top so search engines can find it.

Hey, there

Thank you so much for your detailed reply and extra infor!!

Just wondering though, is it necessary to specify the language as english or whatnot, and the UTF-8? Or in what situation, it is useful?

Thank you!

Is it necessary, yes. Is it mandatory, no. It tells user agents the human readable language of the page so they can know to use standard alphabet. We can specify any language, naturally. So long as we are honest in the page. If a page is readable by an English speaking audience, then telling the user agent to expect German or Hindi won’t make a lot of sense. It’s a useful attribute if we use it correctly.

The lang attribute may be used on any element and is recommended when a change in human readable language occurs in the page.

<span lang="fr">Ceci est écrit en français.</span>

Do you need to know or employ this anywhere in this course? No. Keep this for future reference and make it a habit in any work you do that faces the web.

Most linters will cough if there is no character encoding. This is a no-brainer to immediately and permanently adopt as a best practice. The character set, then the title, in that order, in every page you produce.

Hey, Roy

Thank you very much! :slight_smile:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.