Lesson 7 of 9
HTML5 Content Models
HTML5 organizes all elements into 7 content categories that define which elements can be nested inside which. Understanding content models prevents invalid HTML - for example, <p> can only contain phrasing content, so <p><div>text</div></p> is invalid. Browsers try to fix invalid nesting, often creating unexpected results.
7 Content Categories
- Metadata content - Goes in <head>: <title>, <meta>, <link>, <style>, <script>
- Flow content - Almost everything in <body>: <div>, <p>, <article>, <section>, etc.
- Sectioning content - Creates document outline entries: <article>, <section>, <nav>, <aside>
- Heading content - Headings that define sections: <h1> through <h6>
- Phrasing content - Inline text-level elements: <em>, <strong>, <a>, <span>, <code>, <img>
- Embedded content - External resources: <img>, <video>, <audio>, <canvas>, <iframe>, <svg>
- Interactive content - User-interactable: <a>, <button>, <input>, <select>, <details>
- CRITICAL RULE: <p> can only contain phrasing content. Putting a <div> inside a <p> is INVALID - browsers will auto-close the <p> before the <div>.
Diagram
Loading diagram…
Content categories define valid element nesting rules in HTML specifications
Key Takeaways
- HTML5 organizes all elements into 7 content categories that define which elements can be nested inside which.
- Metadata content - Goes in <head>: <title>, <meta>, <link>, <style>, <script>
- Flow content - Almost everything in <body>: <div>, <p>, <article>, <section>, etc.
- Sectioning content - Creates document outline entries: <article>, <section>, <nav>, <aside>
Finished this lesson?
0 of 9 in Module 7