Document Structure WHATWG HTML

<!DOCTYPE html> doctype <html> <head> <meta> <title> <link> <style> </head> metadata <body> visible content </body> content </html>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Page Title</title>
  </head>
  <body>
    ...
  </body>
</html>

Element Anatomy tags + content

< a tag href="/page" attribute > opening tag Click here content < / a tag > closing tag name = value
<a href="/page">Click here</a>

Void Elements no closing tag

<br> <img src> <input> <meta> <link> self-closing — no content allowed
ElementPurposeCommon Attributes
<br>Line breaknone
<hr>Thematic breaknone
<img>Imagesrc, alt
<input>Form inputtype, name
<meta>Metadatacharset, name
<link>External resourcerel, href
<area>Image map areashape, coords
<base>Base URLhref
<col>Table columnspan
<embed>Embedded contentsrc, type
<source>Media sourcesrc, type
<track>Text tracksrc, kind
<wbr>Word break opportunitynone

Character Entities named + numeric

&amp; & ampersand &lt; < less-than &gt; > greater-than &quot; " quotation entity reference renders as
EntityNumericCharacterWhen Required
&amp;&#38;&Always in content
&lt;&#60;<Always in content
&gt;&#62;>After ]] in content
&quot;&#34;"In quoted attributes
&apos;&#39;'In single-quoted attributes
&nbsp;&#160;(space)Non-breaking space

DOCTYPE rendering mode

<!DOCTYPE html> standards mode present or absent (missing) quirks mode quirks mode emulates legacy browser bugs
ModeTriggered ByBehavior
Standards<!DOCTYPE html>CSS box model, strict parsing
Almost StandardsOlder DOCTYPEs with URLStandards except table cell sizing
QuirksMissing or malformed DOCTYPELegacy IE5 box model, loose parsing

Meta Charset encoding declaration

<meta charset="UTF-8"> explicit declaration windows-1252 default fallback must appear in first 1024 bytes
ScenarioEncoding Used
HTTP Content-Type header specifies charsetHeader value takes precedence
BOM (Byte Order Mark) presentUTF-8 or UTF-16 per BOM
<meta charset="..."> presentSpecified encoding
<meta http-equiv="Content-Type">Charset from content attribute
No declarationwindows-1252 (legacy default)
<!-- Recommended: first element in <head> -->
<head>
  <meta charset="UTF-8">
  <title>...</title>
</head>

Default Attributes implicit values

ElementAttributeDefault Value
<input>type"text"
<button>type"submit"
<script>type"text/javascript"
<style>type"text/css"
<a>target"_self"
<form>method"get"
<form>enctype"application/x-www-form-urlencoded"
<textarea>wrap"soft"
<th>scope"auto"
<link rel="stylesheet">type"text/css"
<ol>type"1"
<ol>start1
<img>decoding"auto"
<video>, <audio>preload"auto" (browser-dependent)