The Tech Platform

Nov 23, 20211 min

Grid - Area Property

The grid-area property specifies a grid item's size and location in a grid layout, and is a shorthand property for the following properties:

  • grid-row-start

  • grid-column-start

  • grid-row-end

  • grid-column-end

Code:

<!DOCTYPE html>
 
<html>
 
<head>
 
<style>
 
.grid-container {
 
display: grid;
 
grid-template-columns: auto auto auto auto;
 
grid-gap: 10px;
 
background-color: pink;
 
padding: 10px;
 
}
 

 
.grid-container > div {
 
background-color: white;
 
text-align: center;
 
padding: 20px 0;
 
font-size: 30px;
 
}
 

 
.item1 {
 
grid-area: 1 / 1 / span 2 / span 3;
 
}
 
</style>
 
</head>
 
<body>
 

 
<h1>The grid-area </h1>
 

 
<p>Item1 will start on row 1 and column 1, and span 2 rows and 3 columns:</p>
 

 
<div class="grid-container">
 
<div class="item1">The Tech Platform</div>
 
<div class="item2">1</div>
 
<div class="item3">2</div>
 
<div class="item4">3</div>
 
<div class="item5">4</div>
 
<div class="item6">5</div>
 
<div class="item7">6</div>
 
</div>
 

 
</body>
 
</html>

Output:

The Tech Platform

www.thetechplatform.com

    0