
How to create a Footer with CSS Grid
Before We Start
Every developer needs clean and modern elements to develop their websites, It contains pictures and a user interface element within a website. The most important one and the first section that the user sees when the user enters a website. How to create a Footer with CSS Grid
So if you are a person who wishes to develop a website, you have to know how to create that properly.

How to create a Footer with CSS Grid
We are here to solve your problem. In this article we discuss how to create these elements. Before we start please read the below articles which easier you to understand the process, if you are new to development.
Step 1 – Add HTML
It’s too easy and simple. Just copy and paste below code in your HTML editor between <body> </body> tag.
<main>
<h1>Fighting the Flying Footer</h1>
<section>
<p>Using <strong>CSS Grid</strong> to position the footer at the bottom - allowing for a variable footer height.</p>
<hr>
<h2>Join the Fight!</h2>
</section>
</main>
<footer>
<p>© Copyright 2020, W3SchoolWeb. All Rights Reserved</p>
</footer>
Step 2 – Add CSS
Copy and paste below code in your HTML editor between <style></style> tag.
<style>
/*Layout styles*/
body{
display:grid;
grid-template-columns: 1fr;
grid-template-rows:1fr auto;
min-height:100vh;
}
//main{
/*use margin 0 to have the element take up all space down to the footer*/
/*margin:0 0 auto 0; /*use margin-bottom auto if you don't want the element to cover the length of the body*/
//}
footer{
margin:0;
}
//----------------------------------------------
/*Cosmetic styles*/
:root{
--modular1: 1.125;
--modular2: 1.414;
--startwidth: 30;
--endwidth:105;
//need these numbers for h6 and p without units for calc.
--base-min: 1;
--base-max:1.25;
--h1-responsive: calc(var(--h1-size) + ((var(--modular2) * var(--modular2) * var(--modular2) * var(--modular2) * var(--modular2)) - (var(--modular1) * var(--modular1) * var(--modular1) * var(--modular1) * var(--modular1))) * ((100vw - (var(--startwidth) * 1em)) / (var(--endwidth) - var(--startwidth))));
--h2-responsive:calc(var(--h2-size) + ((var(--modular2) * var(--modular2)) - (var(--modular1) * var(--modular1))) * ((100vw - (var(--startwidth) * 1em)) / (var(--endwidth) - var(--startwidth))));
--p-responsive:calc(var(--p-size) + ((var(--base-max)) - (var(--base-min))) * ((100vw - (var(--startwidth) * 1em)) / (var(--endwidth) - var(--startwidth))));
--h1-size: calc(var(--modular1) * var(--modular1) * var(--modular1) * var(--modular1) * var(--modular1) * 1em);
//--h2-size: calc(var(--modular1) * var(--modular1) * var(--modular1) * var(--modular1) * 1em);
--h2-size: calc(var(--modular1) * var(--modular1) * 1em);
--p-size:calc(var(--base-min) * 1em);
}
body{
background-color:green;
text-align:center;
font-family:/*ios*/ "HelveticaNeue", /*android*/ "Roboto", /*fallbacks*/ Arial, Verdana, "Trebuchet MS", sans-serif;
color:#584d4d;
}
main{
background-color:#fffaf8;
padding:3em 1em 0 1em;
box-sizing:border-box;
}
footer{
background-color:aliceblue;
padding:0 1em;
box-sizing:border-box;
background-image:linear-gradient(to right, #ff885d 0%,#ff5062 100%);
color:#FFF;
}
h1{
font-family: 'Great Vibes', Arial, Helvetica, sans-serif;
background-image:linear-gradient(to right, #ff885d 0%,#ff5062 100%);
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: rgba(0, 0, 0, 0);
color:#2f2f2f;
font-size: var(--h1-size);
line-height: 1.45669;//42px;
margin:(12/28.8325)+em 0;
}
h2{
font-size: var(--h2-size);
line-height: 1.629629629629; //33
margin:(9/20.25)+em 0;
letter-spacing: 3px;
text-transform: uppercase;
}
p{
line-height:1.5;
margin: 0.75em auto;
font-size:var(--p-size);
}
a{
color: #FFF;
background-image:linear-gradient(to right, #ff7644 0%, #f94456 100%);
text-decoration:none;
padding:0 0.25em;
opacity:0.85;
transition:0.5s opacity;
display:inline-block;
margin:0.5em auto 0;
&:hover, &:focus, &:active{
opacity:1;
}
}
hr{
width:5em;
margin:3em auto;
}
@media only screen and (min-width: 30em) {
h1, h2{
//expression for responsive margins
--margin-responsive: calc((var(--margin-min, 1) * 1rem) + (var(--margin-max, 1.125) - var(--margin-min, 1)) * ((100vw - (var(--startwidth) * 1rem)) / (var(--endwidth) - var(--startwidth))));
margin:var(--margin-responsive) auto;
//expression for responsive line-heights
--lineheight-responsive:calc((var(--lineheight-min) * 1rem) + (var(--lineheight-max) - var(--lineheight-min)) * ((100vw - (var(--startwidth) * 1rem)) / (var(--endwidth) - var(--startwidth))));
line-height: var(--lineheight-responsive);
}
h1{
--margin-min:0.75; //12
--margin-max: 1.875; //30;
--lineheight-min:2.625; //42
--lineheight-max:7.03125;//112.5
font-size:var(--h1-responsive);
}
h2{
font-size:var(--h2-responsive);
--margin-min:0.5625;//9
--margin-max:0.9375;// 15
--lineheight-min: 2.0625;//33px
--lineheight-max: 3.28125;//52.5
}
p{
font-size: var(--p-responsive);
}
}
@media only screen and (min-width: 105em) {
:root{
//changing scales and base
--modular1: var(--modular2);
--base-min: var(--base-max);
}
h1{
font-size: var(--h1-size);
line-height: (112.5/90.4413);
margin: 0.331706864em auto;//30px
}
h2{
font-size: var(--h2-size);
line-height:(52.5/31.9903);
margin:(15/31.9903)+em auto;
}
p{
font-size: var(--p-size);
}
}
</style>
At the end we will have something like this. You can change fonts, colors, backgrounds and all things that you want. Enjoy it.
Your Output

Video Tutorial
Please watch this video to better understand this tutorial and don’t forget to subscribe to our channel.
Help others to find out about this article on Social Media sites. If you have any doubt or any problem, don’t hesitate to contact us. Thereafter we will be able to help you and also make sure you bookmark our site on your browser.