HTML•Semantic HTML5
HTML Semantic Elements: <header>, <main>, <article>, and <footer>
Semantic tags communicate the meaning and purpose of layout sections to browsers and assistive technologies.
Syntax
<header><nav></nav></header>
<main><article></article></main>
<footer></footer>
Parameters & Values
Key components and acceptable values for this structure:
| Parameter | Type | Description |
|---|---|---|
| <main> | Semantic Tag | Contains dominant unique content of document (only one per page). |
| <nav> | Semantic Tag | Declares major navigation link blocks. |
Ready-to-Run Code Example
Executable in CompilraRun this complete, working example directly without installing HTML locally:
<!DOCTYPE html>
<html>
<head>
<style>
body { font-family: sans-serif; margin: 0; display: flex; flex-direction: column; min-height: 100vh; }
header, footer { background: #0f172a; color: white; padding: 15px 20px; }
main { flex: 1; padding: 20px; max-width: 600px; margin: auto; }
article { background: white; border: 1px solid #e2e8f0; border-radius: 8px; padding: 15px; margin-bottom: 15px; }
</style>
</head>
<body>
<header>
<strong>Compilra Platform</strong>
</header>
<main>
<article>
<h2>Zero-Setup Cloud Execution</h2>
<p>Compile and run C++, Python, and Rust code in isolated containers with instant output.</p>
</article>
</main>
<footer>
© 2026 Compilra Technologies. All rights reserved.
</footer>
</body>
</html>Expected Output:
[Semantic Full-Height Page Layout: Dark Header, Centered Content Article, and Dark Sticky Footer]
How It Works: Step-by-Step
- Lines 12-14: <header> defines top brand banner.
- Lines 15-20: <main> and <article> encapsulate core document article.
- Lines 21-23: <footer> renders bottom copyright compliance bar.
Key Concepts
- Replace meaningless <div> soup with semantic tags for accessibility.
- There must be only one <main> element per document.
Common Mistake: Using generic <div> for all layout containers instead of semantic tags
Overusing <div> strips accessibility landmarks from screen readers.
❌ Incorrect
<div id="header">...</div> <div id="footer">...</div>
✅ Correct
<header>...</header> <footer>...</footer>
Related HTML Tutorials & Compiler
HTML5 Semantic Structural Boilerplate and Metadata Configurations
Structure HTML5 documents with semantic boilerplate tags (<!DOCTYPE html>, <meta>, <header>, <main>, <nav>, <footer>) and responsive viewport configurations.
HTML Headings, Paragraphs, and Text Formatting Tags
Structure text content with heading hierarchy (h1 through h6), paragraphs, strong, and code.
HTML Form Validation: Client-Side Input Requirement Attributes and Constraint Tags
Enforce client-side input validation and conditional submission guards using HTML5 constraint attributes (required, pattern, minlength, min/max).
HTML Online Compiler
Open in Compilra IDE
Run and test HTML on Compilra
Execute this code snippet with pre-supplied standard input (stdin) in Compilra’s cloud compiler.