<head>'s content model is metadata content: exactly one <title> (unless a higher-level protocol supplies one, as in srcdoc), at most one <base>, and any number of meta, link, style, script, noscript and template. The important pieces:
<meta charset="utf-8">declares the encoding. The value must be UTF-8, and the element must be fully inside the first 1024 bytes, because browsers prescan those bytes before parsing. A charset in the HTTPContent-Typeheader or a byte-order mark wins over it. Without any declaration the browser guesses, and on an en-US profile both Chrome 155 and Firefox 158 decoded a UTF-8caféserved over HTTP ascafé(windows-1252).<meta name="viewport" content="width=device-width, initial-scale=1">is defined by CSS Viewport, not HTML. Mobile browsers otherwise lay out the page on a wide fallback viewport and zoom out; with the tag, the layout viewport matches the device width and media queries see the real size.<title>names the document in tabs, history, bookmarks and search results; Chrome's accessibility tree uses it as the page's name.document.titlereads the first<title>in the document.<base href>sets the document base URL. Every relative URL resolves against it: links, images,fetch, and evenhref="#id". Only the firstbasewithhrefcounts.targetsets the default browsing context for links and forms.<meta name>carries named metadata: the standard ones includedescription,referrer,theme-color,color-scheme,application-nameandgenerator; others such asrobotsare extensions defined outside the standard.
link elements (stylesheets, icons, canonical) also live here; their relations are their own topic.
The parser enforces "metadata only": the first non-metadata element (a div, text) closes head, and everything after it, including later meta tags, goes into body.