agyanadda@gmail.com

HTML Page Layout

HTML Layout & Structure 1 min read Updated Nov 30, 2026 Topic 19 of 33

A typical page has a header, a navigation bar, a main area, a sidebar and a footer. HTML gives the structure; CSS arranges it on the screen.

Modern layout tools (CSS)

  • Flexbox — arrange items in a row or column. Best for menus and simple two-column layouts.
  • Grid — arrange items in rows and columns. Best for full page layouts.

Old methods like tables and float for layout are no longer recommended.

Example

Example — Two-column layout with Flexbox HTML
<style>
  body { font-family: Arial, sans-serif; margin: 0; }
  header, footer { background: #1e3a8a; color: #fff; padding: 12px; }
  .wrap { display: flex; gap: 12px; padding: 12px; }
  main { flex: 3; background: #f1f5f9; padding: 12px; }
  aside { flex: 1; background: #fef3c7; padding: 12px; }
  @media (max-width: 600px) { .wrap { flex-direction: column; } }
</style>

<header>My Website</header>
<div class="wrap">
  <main>Main content goes here.</main>
  <aside>Sidebar</aside>
</div>
<footer>&copy; 2026</footer>

On small screens the media query stacks the columns.

Try it Now »

Test Yourself With Exercises

Exercise 1 Multiple Choice

Which CSS feature is best for a full page layout in rows and columns?

Exercise 2 True / False

Tables are the recommended way to build page layouts.

Frequently Asked Questions

Start with Flexbox; it is simpler and covers most everyday layouts. Then learn Grid for full page layouts.