Main content goes here.
HTML layouts define how the content of a webpage is arranged visually and logically. Using layouts, we organize different parts of a page like headers, footers, sidebars, and main content areas. This organization helps visitors navigate the website easily and improves the overall user experience. Layouts also allow developers to style and control sections separately, making websites easier to maintain and update.
Modern HTML layouts use semantic tags plus CSS (Flexbox or Grid) to arrange sections:
<!-- Basic semantic layout structure -->
<header>
<h1>Site Title</h1>
</header>
<div class="layout-wrapper">
<aside>
<p>Sidebar content</p>
</aside>
<main>
<p>Main content goes here.</p>
</main>
</div>
<footer>
<p>Footer information</p>
</footer>
Flexbox is a simple way to place sidebar and content side by side:
/* Flex container for sidebar + main content */
.layout-wrapper {
display: flex;
gap: 16px;
}
.layout-wrapper aside {
flex: 0 0 200px;
}
.layout-wrapper main {
flex: 1;
}
<!-- Container for the whole page layout -->
<div class="container-layout">
<!-- Header Section -->
<header class="header">
<h2>My Website Header</h2>
</header>
<!-- Flex container for sidebar and main content -->
<div class="layout">
<!-- Sidebar -->
<aside class="sidebar">
<p>Sidebar content</p>
</aside>
<!-- Main content area -->
<main class="content">
<p>Main content goes here.</p>
</main>
</div>
<!-- Footer Section -->
<footer class="footer">
<p>Footer information</p>
</footer>
</div>
Below is a simple Flexbox-based layout. The sidebar and main content sit side by side on larger screens. On small screens, they naturally stack vertically (because of limited width).
Main content goes here.
<header>, <main>, <aside>, and <footer> for better accessibility and SEO.<div>s; prefer meaningful structure and class names.<div> tags with semantic elements like <header>, <aside>, <main>, and <footer>.