BEUVAULT Course Unit 2 · HTML & DOM
Course 100219 · Web Designing

Unit 2: The DOM Architecture Sandbox

Real-time compilation of HTML elements, attributes, and tree structure.

  • Identify and use core HTML elements (headings, paragraphs, links, lists, tables, images)
  • Understand the DOM tree structure and how nested elements form parent-child relationships
  • Apply character entities and URL encoding to display reserved characters safely
  • Compare legacy framesets with modern iframes and explain when to use each

▸ How this sandbox works

  1. Edit the HTML in the left panel — the Browser Render updates live as you type.
  2. The DOM Tree Structure panel shows how the browser interprets your HTML as a tree of nested elements. Each indent = a child inside a parent.
  3. Click any snippet button (User Profile, Form, etc.) to load a pre-built example and inspect its structure.

Try it: change <h2> to <h1> in the editor and watch both panels update.

Raw HTML Input (edit and see live)
Load:
Browser Render
DOM Tree Structure

0. HTML Syntax — How to Write a Tag

The shape of an element (skeleton):

<tagname attr="value">
  content (text or nested elements)
</tagname>

Semantic — read it as a sentence: the tag name says what kind of element this is; attributes are extra settings (attr="value") that configure it; the content is what goes inside. Tags nest to build a tree. Void elements (like <img>, <br>, <input>) have no content and no closing tag.

  • Tag name — p, a, div, img… (always lowercase).
  • Attribute — href, src, class, alt… written as name="value"; always quote the value.
  • Content — text or other elements nested between the opening and closing tag.
  • Void — no closing tag; e.g. <img src="pic.jpg" alt="...">.
HTML Tag Builder & Syntax Highlighter
tag attribute value content punctuation

                        

1. HTML Fundamentals — Elements, Tags & Attributes

HTML (HyperText Markup Language) is the standard language for creating web pages. It describes the structure of content using a system of tags and attributes. Every HTML document follows a tree hierarchy called the DOM (Document Object Model).

An HTML element typically consists of:

  • An opening tag with optional attributes: <tagname attr="value">
  • The content (text or other nested elements)
  • A closing tag: </tagname>
  • Self-closing elements (void elements) like <br>, <img>, <input> have no closing tag.

2. Core HTML Element Reference

Sectioning & Grouping:

ElementDescriptionAttributes
<div>Generic block-level container (used for layout)global
<span>Generic inline container (used for text styling)global
<header>Introductory content / navigationglobal
<nav>Section with navigation linksglobal
<main>Dominant content of the documentglobal
<section>Thematic grouping of contentglobal
<footer>Footer for its nearest sectioning ancestorglobal
Text Content & Formatting:
ElementDescriptionExample
<h1>-<h6>Headings (h1 = highest, h6 = lowest)<h1>Title</h1>
<p>Paragraph<p>Text</p>
<a>Hyperlink<a href="url">link</a>
<ul> / <ol>Unordered / Ordered list<ul><li>item</li></ul>
<li>List item—
<table>Table containerborder, cellpadding
<tr>Table row—
<th> / <td>Table header / data cellcolspan, rowspan
<img>Embeds an image (void element)src, alt, width, height
<br>Line break (void element)—
<strong>Bold / strong importance—
<em>Italic / emphasized text—

3. Semantic Landmarks — Giving Regions Meaning

Why it matters (semantic): Elements like <header>, <nav>, <main>, <section>, <article>, <aside>, and <footer> aren't just boxes — they are landmarks. Screen readers turn them into a jump menu so users can skip straight to nav, main content, or footers. A page built only from <div>s has no landmarks: assistive tech sees one undifferentiated blob. Toggle the regions below and watch the accessibility tree react.

Semantic Landmarks Visualizer

Toggle each region to include it. Switch to <div>s to see the accessibility tree collapse.

Markup style:

4. Lists — Unordered, Ordered & Description

Three list types, three jobs (skeleton + semantic): <ul> groups unordered items, <ol> marks a sequence / steps (use start, reversed, type), and <dl> (description list) pairs a term → definition — perfect for a glossary, spec table, or metadata. Choose the element that matches your data's meaning, not just how you want it to look.

List Builder (incl. <dl>)
List type:

5. Headings & the Document Outline

Headings are the page's table of contents (skeleton + semantic): <h1> is the most important (usually one per page), <h2>–<h6> mark sub-sections. Together they build an outline that search engines and screen-reader users navigate by — so don't skip levels (h1 → h3) and keep a single h1. Type headings below to build a real outline.

Heading Outline Builder

Use #, ## … ###### to set the level (Markdown-style).

Document outline:

6. HTML Character Entities & URL Encoding

Character entities are used to display reserved characters (like <, >, &) that would otherwise be interpreted as HTML code. They start with & and end with ;.

There are three formats: named (&lt;), decimal numeric (&#60;), and hex numeric (&#x3C;).

CharNamedNumericURL EncodedDescription
<&lt;&#60;%3CLess than (starts tags)
>&gt;&#62;%3EGreater than (ends tags)
&&amp;&#38;%26Ampersand (starts entities)
"&quot;&#34;%22Double quote (attribute values)
'&apos;&#39;%27Single quote / apostrophe
 &nbsp;&#160;%C2%A0Non-breaking space
©&copy;&#169;%C2%A9Copyright symbol
®&reg;&#174;%C2%AERegistered trademark
€&euro;&#8364;%E2%82%ACEuro currency
→&rarr;&#8594;—Right arrow
URL Encoding (percent-encoding) replaces unsafe characters in URLs with a % followed by two hex digits representing the byte. For example, a space becomes %20. The JavaScript function encodeURIComponent() performs this encoding automatically.

7. Frames & Framesets (Legacy) vs Modern Iframes

Framesets (HTML 4 / deprecated in HTML5) divided the browser window into multiple independent sections, each loading a separate HTML document. The <frameset> element replaced <body>, and <frame> defined each region.

Modern HTML uses <iframe> (inline frame) to embed one HTML document inside another. Unlike framesets, iframes work within the <body> and are responsive by default.

Feature<frameset> (Legacy)<iframe> (Modern)
Replaces <body>?Yes — body must be omittedNo — works inside body
Deprecated?Yes — not supported in HTML5No — fully supported
Responsive?No — fixed pixel dimensionsYes — can use CSS width/100%
Attributescols, rowssrc, srcdoc, sandbox, loading

8. The Two Importances: Skeleton vs Semantic

Every HTML element does two jobs. Its skeleton is its anatomy — the tag, required attributes, whether it is void or paired, and its default display. Its semantic value is its meaning: how screen readers, search engines, and other developers interpret it. Choosing <strong> over <b>, or <nav> over <div>, changes nothing visually but changes everything for accessibility and SEO. Pick an element below to see both sides.

HTML Element Explorer

Click an element to inspect its skeleton + semantic:

9. Images & the Alt-Text Contract

Skeleton: <img> is a void element — no closing tag, needs src and alt. Semantic: the alt attribute is the image's text equivalent for screen-reader users and when the image fails to load. Empty alt="" marks a decorative image (intentionally skipped); a missing alt is an accessibility failure. Type alt text and toggle the image state to see what a screen reader announces.

Alt-Text Tester
Sample image

10. Tables — Structure & Accessibility

Skeleton: a table is <table> → <caption> (optional title) → <thead>/<tbody> → <tr> → <th>/<td>. Semantic: use <th scope="col"> so assistive tech maps headers to cells. Never use tables for page layout. Build one below.

Table Builder

10.1 Tables — colspan & rowspan (spanning cells)

What colspan / rowspan do (skeleton + semantic): a normal <td>/<th> sits in one slot. colspan stretches a cell sideways across columns; rowspan stretches it downwards across rows. Below, pick one concept, drag the slider, and watch a single highlighted cell swallow the grey cells it covers. Screen readers still read a spanned cell once — so use spans for real grouping, not fake layout.

Colspan / Rowspan Playground
What should the cell stretch across?

The highlighted cell grows and merges the grey cells it covers. Its generated tag is shown below.

Generated HTML (the highlighted cell)

                        

11. The Document Boilerplate

Skeleton: every page starts with <!DOCTYPE html>, a <html lang="..."> root, a <head> with <meta charset>, <meta viewport>, and a <title>, then a <body>. Semantic: lang tells screen readers which language to use (a11y + SEO); <title> is the tab label and the primary search-result text. Toggle the parts to assemble the skeleton.

Boilerplate Builder

                    

ASCII vs Unicode vs UTF-8

Understanding the difference between these three is critical for building web applications that handle text correctly across languages:

  • ASCII (1960s) — 7-bit encoding, 128 characters (A-Z, a-z, 0-9, punctuation, control codes). Only covers English. Each character = 1 byte.
  • Unicode (1990s) — A universal character set assigning every character from every writing system a unique code point (e.g., U+0041 = 'A', U+0905 = 'अ', U+1F600 = '😀'). It does NOT define how bytes are stored — only the mapping.
  • UTF-8 — The dominant encoding on the web (>98% of pages). It stores Unicode code points in 1-4 bytes. ASCII characters (U+0000-U+007F) use 1 byte — making UTF-8 backward compatible with ASCII. Non-Latin scripts use 2-4 bytes.

Why This Matters for HTML

The <meta charset="UTF-8"> declaration tells the browser to interpret the page as UTF-8. Without it, the browser may guess the encoding (often Western/ASCII), which breaks special characters, emojis, and non-Latin scripts. Always include <meta charset="UTF-8"> in the <head>.

Character Entities vs Raw Unicode

You can include any Unicode character directly in your HTML if the file is saved as UTF-8:

<p>日本語, हिन्दी, ελλάδα, 😀 are all valid in UTF-8</p>

Use character entities only for characters that have special meaning in HTML: &lt; (<), &gt; (>), &amp; (&), &quot; ("). Everything else is better as the literal character.