Understanding Semantic Web
Articles represent standalone, reusable content items.
Understand the boilerplate structure of every HTML document including doctype, html, head, and body tags.
When a web browser downloads an HTML document from a server, it does not simply render plain text line by line. Instead, the browser's HTML parser transforms the raw markup into a structured hierarchical memory model called the Document Object Model (DOM) Tree.
Understanding this tree hierarchy is essential for mastering layout design, CSS targeting, and JavaScript manipulation.
<html> element is the ultimate top-level parent node of the entire document tree.<body> is the parent of <main> or <h1>.<li> nodes are children of a <ul> parent.<article>).<!-- DOM Tree Representation -->
<html> <!-- Root Node -->
<head></head> <!-- Child of html, Sibling of body -->
<body> <!-- Child of html, Parent of main -->
<main> <!-- Child of .tech-lesson-content, Parent of h1 and p -->
<h1>Heading</h1> <!-- Child of main, Sibling of p -->
<p>Paragraph text.</p> <!-- Child of main, Sibling of h1 -->
</main>
</body>
</html>
Malformed HTML (like unclosed tags or invalid tag nesting) breaks the browser's DOM parsing engine. When the DOM tree breaks, CSS styling fails, layout shifts occur, and JavaScript event listeners cannot locate targets correctly.
Every HTML element has a default display behavior defined by the browser's user-agent stylesheet. HTML elements fall primarily into two fundamental display categories: Block-Level Elements and Inline Elements.
| Feature / Property | Block-Level Elements | Inline Elements |
|---|---|---|
| Default Line Behavior | Always starts on a fresh new line. Forces subsequent elements down. | Sits gracefully in-line alongside surrounding text or elements without breaking lines. |
| Width Behavior | Expands horizontally to fill 100% of available parent width by default. | Takes up only as much width as its enclosed content requires. |
| Height & Width Customization | Accepts explicit CSS width and height properties. |
Ignores explicit CSS width and height properties. |
| Margin & Padding | Respects top, bottom, left, and right margins and padding completely. | Respects horizontal (left/right) margin/padding, but ignores vertical (top/bottom) margins. |
| Common Element Examples | <div>, <p>, <h1>-<h6>, <ul>, <li>, <article>, <header> |
<span>, <a>, <strong>, <em>, <code>, <img> |
<!-- Block Elements (Stack Vertically) --> <p style="background: #e2e8f0;">I am a Block element (Paragraph 1).</p> <p style="background: #cbd5e1;">I am a Block element (Paragraph 2).</p> <!-- Inline Elements (Sit Side-by-Side) --> <span style="background: #fef08a;">Inline Item 1</span> <span style="background: #bbf7d0;">Inline Item 2</span> <span style="background: #bfdbfe;">Inline Item 3</span>
I am a Block element (Paragraph 1).
I am a Block element (Paragraph 2).
Inline Item 1 Inline Item 2 Inline Item 3When no specific semantic element applies, HTML provides two generic container elements used exclusively for grouping content for CSS styling or JavaScript interaction.
A <div> is a non-semantic block-level container. It carries no inherent structural meaning or SEO value. It is used to group large sections of HTML together to apply layout styling (like CSS Flexbox or CSS Grid) or CSS background colors.
A <span> is a non-semantic inline container. It is used to isolate specific words, phrases, or characters inside a block element to apply target text styling (such as changing color, font weight, or background highlight) without breaking the sentence flow.
<!-- Combining div and span -->
<div style="background: #f1f5f9; padding: 15px; border-radius: 6px;">
<h3 style="margin-top: 0;">Container Title</h3>
<p>This paragraph lives inside a div container, but this <span style="color: #2563eb; font-weight: bold;">blue highlighted phrase</span> is isolated inside a span.</p>
</div>
This paragraph lives inside a div container, but this blue highlighted phrase is isolated inside a span.
Overusing nested <div> elements everywhere instead of proper semantic tags (like <header>, <article>, <footer>) creates unmaintainable code known as "Div Soup", which hurts page accessibility and SEO performance.
Modern HTML5 documents divide full web pages into clear, logical, and standardized structural regions using semantic sectioning elements.
<!-- Complete Semantic Page Architecture -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Semantic Web Architecture</title>
</head>
<body>
<!-- Top Site Header -->
<header>
<h1>Tech Journal</h1>
<nav>
<a href="#home">Home</a> | <a href="#articles">Articles</a>
</nav>
</header>
<!-- Main Viewport Content -->
<main>
<article>
<h2>Understanding Semantic Web</h2>
<p>Articles represent standalone, reusable content items.</p>
</article>
<aside>
<h3>Related Posts</h3>
<p>Sidebar links and supplementary info.</p>
</aside>
</main>
<!-- Global Footer -->
<footer>
<p>© 2026 Tech Journal. All rights reserved.</p>
</footer>
</body>
</html>
Articles represent standalone, reusable content items.
<header>: Defines global introductory branding, site titles, or primary navigation wrappers.<nav>: Reserved specifically for primary site navigation link lists.<main>: Represents the unique, primary content core of the document. Must appear only once per page.<article>: Self-contained content blocks intended for independent distribution (e.g., blog posts, news stories, forum comments).<section>: Logical thematic groupings of content, usually containing an explicit heading.<aside>: Indirectly related content such as sidebars, advertising blocks, author bios, or related link groups.<footer>: Contains copyright notices, privacy policy links, sitemaps, and author contact details.Create an index.html file representing a mini news site. Build a complete layout using <header>, <nav>, <main> containing two <article> nodes, an <aside> sidebar, and a <footer>. Ensure zero non-semantic <div> tags are used for sectioning.
Write an HTML file containing three paragraphs. Inside the second paragraph, use three separate <span> tags to highlight individual words with different inline CSS background colors. Add a <div> container wrapping paragraphs 2 and 3, and explain how the container manages their layout.
Combine knowledge from Lessons 01 through 05: Construct a complete valid HTML5 page, open it in Chrome DevTools, expand the DOM tree in the Elements Panel, identify the parent-child-sibling relationships between <main>, <article>, and <p>, and validate your code through validator.w3.org.
Answer: An <article> is a completely self-contained piece of content that makes logical sense on its own if syndicated or shared independently (e.g., a news article, blog post, or product card). A <section> is a thematic grouping of related content within a larger page, typically requiring an accompanying heading (e.g., "Features Section", "Contact Section").
Answer: By specification, inline elements (like <span> or <em>) are designed to live inside text streams and cannot contain structural block-level containers (like <div> or <p>). Nesting a block element inside an inline element breaks line layout rendering. (Note: HTML5 explicitly allows anchor tags <a> to wrap entire block elements for hyperlinking purposes).
Answer: HTML source code is plain text written by developers. The DOM is an in-memory object tree generated by the browser parser after reading that raw HTML text. JavaScript manipulates the DOM in memory to dynamically update elements, styles, and content without needing to edit the raw HTML file stored on disk.
Answer: The <main> element highlights the core, non-repeating content unique to that specific URL. Including multiple <main> elements creates ambiguity for accessibility software (screen readers use <main> as a primary landmark to skip navigation menus) and violates HTML5 validation rules.