top of page

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

Value

Description

grid-row-start

Specifies on which row to start displaying the item.

grid-column-start

Specifies on which column to start displaying the item.

grid-row-end

Specifies on which row-line to stop displaying the item, or how many rows to span.

grid-column-end

Specifies on which column-line to stop displaying the item, or how many columns to span.

itemname

Specifies a name for the grid item




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

0 comments

Comments


bottom of page