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>© 2026</footer>
On small screens the media query stacks the columns.
Try it Now »