CSS · CSS Tutorial · Lesson 37
CSS Website Layout
Header, navigation, content and footer.
A website is often divided into a header, a menu, content columns and a footer.
Example
<style>
* { box-sizing: border-box; }
body { margin: 0; font-family: Arial; }
.header { background: #04AA6D; color: white; padding: 20px; text-align: center; }
.topnav { background: #333; display: flex; }
.topnav a { color: #f2f2f2; padding: 12px 16px; text-decoration: none; }
.row { display: flex; flex-wrap: wrap; }
.side { flex: 30%; background: #f1f1f1; padding: 20px; }
.main { flex: 70%; padding: 20px; }
.footer { padding: 20px; text-align: center; background: #ddd; }
@media (max-width: 600px) { .row { flex-direction: column; } }
</style>
<div class="header"><h1>My Website</h1></div>
<div class="topnav"><a href="#">Link</a><a href="#">Link</a><a href="#">Link</a></div>
<div class="row">
<div class="side"><h2>About Me</h2><p>Sidebar text.</p></div>
<div class="main"><h2>TITLE HEADING</h2><p>Main content goes here.</p></div>
</div>
<div class="footer">Footer</div>
Keep reading “CSS Website Layout”
Sign up to read the full lesson, try every example in the live editor, and take the 5-question quiz.