What You'll Learn
You'll learn how HTML exemplifies declarative programming by describing what a document is, not how to construct it.
What is HTML?
HTML (HyperText Markup Language) is a markup language that declaratively describes the structure and content of web documents. Unlike imperative programming where you write step-by-step instructions with control flow (loops, conditionals, assignments), HTML simply states what exists in the document.
When you write HTML, you don't tell the browser "first create a heading, then move down, then create a paragraph." Instead, you declare the document's structure:
<article>
<h1>Welcome</h1>
<p>This is a paragraph.</p>
</article>
You're saying: "This document contains an article with a heading and paragraph." The browser figures out how to render it—you just describe the what.
No Control Flow
HTML has no variables, no loops, no conditionals, and no side effects. It's purely descriptive. You can't write:
- "If user is logged in, show profile"
- "Loop 10 times to create rows"
- "Assign this value and increment a counter"
This is the essence of declarative programming: you specify the desired outcome (document structure), and the system (browser) handles the implementation details.
Why Markup, Not Programming?
A markup language annotates content with structural meaning. Tags like <em> declare "this text is emphasized," not "make this italic." The browser decides the presentation. This separation of concerns—content structure vs. rendering logic—makes HTML powerful for documents.
Compare to imperative code where you'd explicitly command each rendering step with mutations and control flow.
Key Takeaway:
HTML declaratively describes document structure using markup tags without programming constructs like variables, loops, or control flow—you state what the document contains, not how to build or display it.