Sign up to save progress, unlock study materials, and track your learning.
Bookmark content and pick up later
AI-generated study materials
Flashcards, timelines, and more
Progress tracking and certificates
Free to join · No credit card required
HTML Structure and Semantics — The DOM's Table of Contents
"This is the moment where the concept finally clicks: HTML isn't just boxes — it's meaning."
You're coming off relational databases and SQL — you modeled data, kept integrity, and wrote queries that don't make your future self cry. Nice. Now imagine the data you've lovingly normalized: it's got to go somewhere people can actually read it. Enter HTML structure and semantics — the blueprint that turns rows and columns into readable, accessible web pages.
What is HTML structure and why semantics matter
HTML structure = how you nest tags to create the Document Object Model (DOM). Think of it as the outline of a web page.
Semantics = choosing tags that describe meaning (not just appearance). For example, means “page header”, means “a self-contained story”.
Why it matters:
Accessibility: Screen readers rely on semantics to navigate content. Using , , is like adding signposts for assistive tech.
SEO & discoverability: Search engines use semantic tags to understand what your content is about — similar to how an indexed database column helps queries run faster.
Maintainability: Semantically clear HTML is easier to style with CSS and manipulate with JavaScript — like having a clean schema vs. a messy dump.
Quick analogy for CS50 students
If your database schema defines what information exists and how it's related, semantic HTML defines how that information is organized for human consumption. A good HTML structure is to a web page what a good schema is to a database.
Micro explanation: doctype tells browsers to use modern standards, helps accessibility and search engines, and signals the core content — which is important for screen readers and SEO.
Common semantic tags and when to use them
— page or section header (logo, site title, top nav)
— major navigation links
— the principal content of the document
— a self-contained piece (blog post, forum post)
— thematic grouping inside an article or page
+ — images or illustrations with captions
— contact information
Why not just
s everywhere? Because a
is semantically empty — it's like labeling every table as misc_table in your DB. Works, but unhelpful.
Semantic vs non-semantic: quick comparison
Semantic tag
Non-semantic equivalent
Why prefer semantic?
Screen readers can jump directly to navigation
Search engines recognize standalone content
/
Provides document landmarks
Examples: mapping SQL results to semantic HTML
Imagine you ran a SQL query returning blog posts (id, title, body, author, created_at). How do you render that semantically?
<main>
<section aria-label="Blog posts">
<!-- for each row in result set -->
<article>
<header>
<h2>Post Title</h2>
<p><time datetime="2026-03-12">March 12, 2026</time> — by <span class="author">Ada</span></p>
</header>
<p>Post body...</p>
<footer>Tags, comments link</footer>
</article>
</section>
</main>
Micro explanation: Each SQL row becomes an . The
Accessibility and ARIA: semantic HTML first, ARIA second
Use semantic tags whenever possible. ARIA (Accessible Rich Internet Applications) attributes are for when semantics alone can't express role or state.
Comments (0)
Please sign in to leave a comment.
No comments yet. Be the first to comment!