<h2>Specifying a Grid Item's Placement Using span</h2>
  <p>Use the button to toggle grid placement for the 10th grid item via the <code>span</code> keyword for both row and column spanning.</p>
  <div class="btns">
    <button>Toggle Grid Spanning</button>
  <div class="container">
    <div class="item">1</div>
    <div class="item">2</div>
    <div class="item">3</div>
    <div class="item">4</div>
    <div class="item">5</div>
    <div class="item">6</div>
    <div class="item">7</div>
    <div class="item">8</div>
    <div class="item">9</div>
    <div class="item">10</div>
    <div class="item">11</div>
    <div class="item">12</div>
    <div class="item">13</div>
    <div class="item">14</div>
    <div class="item">15</div>
    <div class="item">16</div>
  <div class="dir">
    <label for="ltr">left-to-right <input type="radio" value="ltr" name="direction" id="ltr" checked></label>
    <label for="rtl">right-to-left <input type="radio" value="rtl" name="direction" id="rtl"></label>
body {
  font-family: Arial, sans-serif;
  font-size: 20px;
  padding: 0 20px 30px;
  line-height: 1.4;

main {
  max-width: 800px;
  margin: 0 auto;

h2 {
  text-align: center;

code {
  font-family: Consolas, monospace;
  background: #ccc;
  padding: 1px 3px;

.btns {
  text-align: center;

button {
  margin: 0 auto 1em;

.container {
  border: solid 2px;
  background: #f8ddf0;
  margin-bottom: 1em;
  padding: 4px;
  display: grid;
  grid-template-rows: repeat(4, 1fr);
  grid-template-columns: repeat(4, 1fr);

.gridtemplateareas .item:nth-child(10) {
  grid-row-start: span 3;
  grid-column-start: span 2;

.ltr {
  direction: ltr;

.rtl {
  direction: rtl;

.dir {
  text-align: center;

label {
  margin-right: 1.3em;
  padding: 8px;

.item {
  background: #c565a8;
  border: solid 2px #305077;
  text-align: center;
  font-size: 2em;
  margin: 4px;
  color: #fff;
  font-weight: bold;
let container = document.querySelector('.container'),
    dirs = document.querySelector('.dir').querySelectorAll('input');

document.querySelector('button').addEventListener('click', function () {
}, false);

for (i of dirs) {
  (function(i) {
    i.addEventListener('click', function() {
      clearClasses(container, dirs);
    }, false);

function clearClasses (el, cl) {
  for (i of cl) {

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.