Skip to main content

Beginner-Friendly Topic

Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!

Lesson 4 of 8

The Head Element & Document Setup

The <head> section contains metadata about the page - title, character encoding, viewport settings, stylesheets, scripts, and search engine instructions. Nothing in <head> is visible on the page, but it controls how the page appears in search results, social media, and different devices.

15 minBy Priygop Editorial TeamUpdated 2026Peer Reviewed & Verified

Essential Head Elements

  • <!DOCTYPE html> - Tells browsers to use HTML5 standards mode. Always the first line.
  • <html lang='en'> - Sets the page language for screen readers and translation tools.
  • <meta charset='UTF-8'> - Character encoding. UTF-8 supports all languages and emoji. Must be first meta tag.
  • <meta name='viewport' content='width=device-width, initial-scale=1'> - Essential for mobile. Without it, mobile browsers render at desktop width.
  • <title>Page Title</title> - Shown in browser tab, bookmarks, and Google search results. Keep under 60 characters.
  • <meta name='description' content='...'> - Google search result snippet. Keep 155-160 characters. Include keywords naturally.
  • <link rel='stylesheet' href='style.css'> - External CSS. Put in head for render-blocking (styles load before content).
  • <link rel='icon' href='favicon.ico'> - Browser tab icon. Also provide Apple touch icon for iOS home screen.
  • <link rel='canonical' href='...'> - Tells search engines which URL is the 'original' to avoid duplicate content penalties.
Diagram
Loading diagram…

The head element configures encoding, responsive viewports, and asset links

Key Takeaways

  • The <head> section contains metadata about the page - title, character encoding, viewport settings, stylesheets, scripts, and search engine instructions.
  • <!DOCTYPE html> - Tells browsers to use HTML5 standards mode. Always the first line.
  • <html lang='en'> - Sets the page language for screen readers and translation tools.
  • <meta charset='UTF-8'> - Character encoding. UTF-8 supports all languages and emoji. Must be first meta tag.

Finished this lesson?

0 of 8 in Module 10
Sign in to save progress

Hands-on Practice Tools for this Course

Test what you learn using these free in-browser developer utilities (no signup required).

All 40+ Tools

Topics in This Module

0/8 done