Basic HTML Page layout using Div tags
A page layout divides the page into parts like header, menu, content, sidebar and footer. The modern way is to use <div> tags (or semantic tags) with CSS Flexbox.
HTML and CSS code
<style>
* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, sans-serif; }
.header, .footer { background: #0073aa; color: #fff; padding: 15px; text-align: center; }
.menu { background: #333; }
.menu a { display: inline-block; color: #fff; padding: 12px 16px; text-decoration: none; }
.wrapper { display: flex; }
.content { flex: 3; padding: 15px; }
.sidebar { flex: 1; background: #f1f1f1; padding: 15px; }
@media (max-width: 600px) {
.wrapper { flex-direction: column; }
}
</style>
<div class="header"><h1>My Website</h1></div>
<div class="menu">
<a href="#">Home</a>
<a href="#">About</a>
<a href="#">Contact</a>
</div>
<div class="wrapper">
<div class="content">
<h2>Main Content</h2>
<p>This is the main area of the page.</p>
</div>
<div class="sidebar">
<h3>Sidebar</h3>
<p>Links or ads go here.</p>
</div>
</div>
<div class="footer">© 2025 My Website</div>
Output in the browser:
Output in the browser
How it works
.wrapperusesdisplay: flex, so the content and sidebar sit side by side.flex: 3andflex: 1give the content three times the width of the sidebar.- The media query stacks them on small phone screens.
Related: HTML Responsive Design and the older table layout.
Learn more about the similar topics:
| Tutorials |
|---|
| HTML Semantic Elements |
| HTML Responsive Design |
| Exercises & Assignments |
|---|
| Write an HTML program to create a navigation menu |
| Write an HTML program to create a page layout with semantic elements |