A Grid-Template-Areas Intro For Beginners

Image for post
Image for post
Demo Layout Used by MDN
<section id="page">
<header>Header</header>
<nav>Navigation</nav>
<main>Main area</main>
<footer>Footer</footer>
</section>
#page {
display: grid;
width: 100%;
height: 250px;
grid-template-areas: "head head"
"nav main"
"nav foot";
grid-template-rows: 50px 1fr 30px;
grid-template-columns: 150px 1fr;
}
#page > header {
grid-area: head;
background-color: #8ca0ff;
}
#page > nav {
grid-area: nav;
background-color: #ffa08c;
}
#page > main {
grid-area: main;
background-color: #ffff64;
}
#page > footer {
grid-area: foot;
background-color: #8cffa0;
}

Using grid-template-areas

grid-template-areas: "head head"
"nav main"
"nav foot";
#page > header {
grid-area: head;
background-color: #8ca0ff;
}

#page > nav {
grid-area: nav;
background-color: #ffa08c;
}

#page > main {
grid-area: main;
background-color: #ffff64;
}

#page > footer {
grid-area: foot;
background-color: #8cffa0;
}

Written by

Front-end Web Developer. Language lover. Traveler. Dude.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store