<!DOCTYPE html>
<html>
<head>
<style>
.grid {
display: grid;
grid-template-columns: repeat(3, 1fr); /* 3 equal columns */
gap: 10px;
}
.grid div {
background: lightcoral;
padding: 20px;
text-align: center;
}
</style>
</head>
<body>
<div class="grid">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
</div>
</body>
</html>
Explanation:
display: grid;
arranges items into a grid.grid-template-columns: repeat(3, 1fr);
makes 3 equal columns.gap
: space between items.
Leave a Reply