CHAPTER 39

CSS Website Layout

Learn the major parts of a website layout and how CSS can organize them into a professional page structure.

01. What is CSS Website Layout?

A website layout defines how headers, navigation, content, sidebars and footers are arranged.
Modern layouts commonly use Flexbox and CSS Grid.
Responsive layouts adapt to different screen sizes.

02. Syntax

.layout { display: grid; grid-template-columns: 250px 1fr; gap: 20px; }

03. Example

CSS / HTML Example AIFA Coding Lab
<!DOCTYPE html>
<html>
<head>

<style>

.page {

    display: grid;

    grid-template-columns:
        240px 1fr;

    min-height: 500px;

}

.sidebar {

    background: #020617;

    color: white;

    padding: 20px;

}

.content {

    padding: 30px;

    background: #eff6ff;

}

@media(max-width:700px) {

    .page {

        grid-template-columns: 1fr;

    }

}

</style>

</head>

<body>

<div class="page">

    <aside class="sidebar">
        Sidebar
    </aside>

    <main class="content">
        Main Content
    </main>

</div>

</body>
</html>

04. Important Points

✓ Use semantic HTML for major layout areas.
✓ CSS Grid is useful for two-dimensional page layouts.
✓ Flexbox is useful for one-dimensional alignment.
✓ Always consider mobile responsiveness.

05. Common Mistakes

⚠ Creating fixed layouts that cannot adapt to mobile.
⚠ Using too many nested containers.
⚠ Using tables for complete website layouts.
⚠ Ignoring semantic structure.

06. Real World Use

Website layouts are used for business websites, education portals, dashboards, blogs, e-commerce sites and web applications.

Ready to Practice? 🚀

Open the AIFA CSS Editor and practice this chapter live.

Try It Yourself →
Practice Exercise

Build a Website Layout

Create a layout containing Header, Sidebar, Main Content and Footer. Make it responsive for mobile.