Dofactory.com
Dofactory.com
Earn income with your CSS skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

CSS grid-column-end

The grid-column-end property sets the end column for a grid item.

The value can also be a range of columns with a span n value

Columns with insufficient or no items will be left blank or empty.

Example

#

Item 2 has a grid-column-end value of 4. It ends before column 4, thereby leaving the preceding column blank.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<style>
  .grid-container {
    background-color: steelblue;
    padding: 10px;
    display: grid;
    grid-gap: 10px;
    grid-template-columns: auto auto auto auto auto;
  }

  .grid-container > div {
    background-color: aliceblue;
    text-align: center;
    padding: 15px 5px;
    font-size: 18px;
  }
</style>

<div class="grid-container">
  <div>1</div>
  <div style="grid-column-end: 4;
              background-color: salmon;
              color: white;">2</div>
  <div>3</div>
  <div>4</div>
  <div>5</div>
  <div>6</div>
  <div>7</div>
  <div>8</div>
  <div>9</div>
  <div>10</div>
  <div>11</div>
  <div>12</div>
  <div>13</div>
  <div>14</div>
  <div>15</div>
</div>

Syntax

grid-column-end: auto | column | span n;

Values

#

Value Description
auto Default. Item follows regular grid flow.
column Sets the column at which to end the display of the item.
span n Sets the number of columns the item will span. n = integer.

More Examples

Click the buttons to see different grid-column-end values.

1
2
3
4
5
6
7
8
9
10
11
12
<style>
  .grid-contain {
    background-color: steelblue;
    padding: 10px;
    display: grid;
    grid-gap: 10px;
    grid-template-columns: auto auto auto auto;
  }

  .grid-contain > div {
    background-color: aliceblue;
    padding: 10px 5px;
    text-align: center;
    font-size: 18px;
  }
</style>

<div class="grid-contain">
  <div>1</div>
  <div style="color: white;
       background-color: salmon;
       grid-column-end: span 3;">2</div>
  <div>3</div>
  <div>4</div>
  <div>5</div>
  <div>6</div>
  <div>7</div>
  <div>8</div>
  <div>9</div>
  <div>10</div>
  <div>11</div>
  <div>12</div>
</div>

Browser support

This table shows when grid-column-end support started for each browser.

Chrome
57 Mar 2017
Firefox
52 Mar 2017
IE/Edge
16 Sep 2017
Opera
44 Mar 2017
Safari
10 Sep 2016

You may also like


Last updated on Sep 30, 2023

Earn income with your CSS skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

Guides