</> Code Corner

HTML · HTML Tutorial · Lesson 29

HTML Layout

Semantic layout elements and techniques.

Websites often display content in multiple columns, like a magazine. HTML has semantic elements that define the different parts of a page:

Element Defines
<header> A header for a document or section
<nav> A set of navigation links
<section> A section in a document
<article> Independent, self-contained content
<aside> Content aside from the main content (like a sidebar)
<footer> A footer for a document or section

Example

<style>
header, footer { background: #555; color: white; padding: 10px; text-align: center; }
.row { display: flex; }
nav { background: #ccc; padding: 10px; width: 30%; }
article { background: #f1f1f1; padding: 10px; flex: 1; }
</style>
<header><h2>Cities</h2></header>
<div class="row">
  <nav><ul><li>London</li><li>Paris</li><li>Tokyo</li></ul></nav>
  <article><h1>London</h1><p>London is the capital city of England.</p></article>
</div>
<footer><p>Footer</p></footer>

Layout Techniques

Keep reading “HTML Layout”

Sign up to read the full lesson (1 more parts), try every example in the live editor, and take the 5-question quiz.

Chat with us 👋