
Understanding layout theory is helpful, but many learners want to see exactly how a real layout comes together. In this practical tutorial, you will learn how to divide web page in HTML by building a complete dashboard-style layout with a header, a navigation sidebar, a main content area containing cards, and a footer. You will use semantic HTML for structure and CSS Grid template areas for positioning, then make the layout responsive so it works beautifully on phones, tablets, and desktops.
Work With AAMAX.CO for Custom Layouts
Complex layouts for dashboards, portals, and content-rich websites require careful planning and precise implementation. AAMAX.CO is a full-service digital marketing company offering web development, digital marketing, and SEO services worldwide. Their developers specialize in responsive interfaces and data-rich applications that remain intuitive at every screen size. If your project involves dashboards or user portals, their web application development team can deliver interfaces that are both functional and visually refined.
Planning the Layout
Our goal on desktop is a header spanning the full width at the top, a fixed-width sidebar on the left, a flexible content area on the right, and a footer across the bottom. On mobile, the sections will stack vertically in a single column, with the sidebar navigation appearing below the header. Sketching this structure first clarifies which HTML elements you need and how CSS will arrange them.
Step 1: Write Semantic HTML
Create a wrapper div with a class such as layout. Inside it, add a header element for the logo and user menu, a nav element for the sidebar links, a main element for the content, and a footer element for closing information. The markup looks like this:
<div class="layout"> <header class="site-header">...</header> <nav class="sidebar">...</nav> <main class="content">...</main> <footer class="site-footer">...</footer></div>Notice that the content order makes sense even without CSS: header, navigation, main content, and footer. This logical order benefits screen reader users and search engines.
Step 2: Define the Grid With Template Areas
In your stylesheet, set the layout wrapper to display grid and give it a minimum height of the full viewport. Define two columns: a sidebar width such as 260 pixels and a flexible one fr column for content. Define three rows: auto for the header, one fr for the middle, and auto for the footer. Then use grid-template-areas to name each region, describing the header across both columns in the first row, the sidebar and content side by side in the second row, and the footer across both columns in the final row. Visually, the CSS reads almost like a map of the page.
Step 3: Assign Elements to Areas
Give each element a grid-area property matching the names you defined: header, sidebar, content, and footer. The browser places each element in its region automatically. Because the layout is defined in one place, you can rearrange the entire page by editing the template areas without touching the HTML.
Step 4: Divide the Content Area Into Cards
Inside the main element, add a section containing several article elements representing dashboard cards, such as statistics, recent activity, and quick actions. Turn that section into its own grid using repeat with auto-fit and minmax, for example a minimum card width of 240 pixels and a maximum of one fr. This nested grid automatically places as many cards per row as space allows, wrapping them on smaller screens without media queries.
Step 5: Style Each Region
Add background colors, padding, and borders to visually distinguish regions. Give the header and sidebar subtle backgrounds, and give cards a light surface with rounded corners and soft shadows. Use the gap property on grids for consistent spacing instead of adding margins to individual elements. Consistent spacing creates a clean, professional appearance.
Step 6: Make It Responsive
Following a mobile-first approach, define the default grid as a single column with template areas stacked vertically: header, sidebar, content, and footer. Then add a media query for screens at least 900 pixels wide that switches to the two-column template described earlier. On small screens, you may also convert the sidebar navigation into a horizontal scrolling list or a collapsible menu toggled with a button, saving vertical space for content.
Step 7: Keep the Sidebar and Header in View
For dashboards, it is often useful to keep navigation visible while content scrolls. Apply position sticky to the header with a top value of zero, and make the sidebar sticky with an offset equal to the header height. Alternatively, make the content area scroll independently by setting a fixed height on the layout and overflow auto on the main element. Test carefully to ensure scrolling feels natural on touch devices.
Step 8: Check Accessibility
Add an aria-label to the nav element, such as Main navigation, so screen reader users understand its purpose. Include a skip link at the top of the page that jumps directly to the main content, which is particularly helpful for keyboard users on pages with long navigation. Verify color contrast for text in each region and ensure focus outlines remain visible.
Debugging Layouts With Developer Tools
Modern browser developer tools include grid and flexbox inspectors. Enable the grid overlay to see line numbers, area names, and gaps drawn directly on the page. This visual feedback makes it much easier to diagnose alignment issues and understand how your template areas map to the screen.
Conclusion
Dividing a web page in HTML becomes intuitive when you combine semantic elements with CSS Grid template areas. Define your regions in HTML, map them visually in CSS, nest additional grids for components like cards, and adapt the template for different screen sizes with a mobile-first media query. This approach produces layouts that are clean, maintainable, accessible, and ready for real-world projects.
