A small piece of HTML can change what a visitor sees or how the browser understands a page. In this lesson, you will explore content models: where elements are allowed using a short example that you can inspect and change.
The Idea in Plain English
The HTML specification defines what kind of content belongs inside each element. A list uses li children, a table has structural row and cell rules, and a paragraph accepts phrasing content rather than div elements.
You can test this using a small local HTML file. Change one part at a time and check the result in the browser before adding more code.
A Working Example
Read the sample once before copying it. Notice the element names and attribute values, then compare them with the explanation below.
<section>
<h2>Shopping List</h2>
<ul>
<li>Bread</li>
<li>Milk</li>
</ul>
</section>
What Each Part Does
- A section groups material about a related topic and usually has a heading.
- The h2 identifies a major subsection.
- A ul is an unordered list of related items.
A browser may fix invalid nesting automatically, so a page that looks fine can still have an unexpected DOM tree.
Try It Yourself
Try this next: identify why a button cannot contain an interactive link. Then inspect the page and explain what changed.
Common Beginner Mistakes
- Checking only whether a page looks correct while ignoring the semantic nesting rules.
- Changing several parts of the example at once, making it difficult to see which part caused a different result.
- Choosing a tag only because its default appearance looks right, without checking whether it describes the content correctly.
Key Takeaways
- The HTML specification defines what kind of content belongs inside each element. A list uses li children, a table has structural row and cell rules, and a paragraph accepts phrasing content rather than div elements.
- A browser may fix invalid nesting automatically, so a page that looks fine can still have an unexpected DOM tree.
- Test the markup in a browser, and check accessibility and real-world behavior where relevant.