Join egghead, unlock knowledge.

Want more egghead? It's 45% off for a limited time only!

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock All Content for 45% Off

Already subscribed? Sign In

Save 45% for a limited time.

Get access to all courses and lessons on egghead today.

Autoplay

    Specify a grid gutter size with grid-gap

    Rory SmithRory Smith

    It’s beautifully straightforward to add a gutter to our grid layout. Let’s apply one with grid-gap.

    cssCSS
    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Transcript

    Transcript

    00:01 In our mockup, we have 10 grid items within a container and our container is a grid. It's taking up all of the available height and it has three grid template columns. There's not space between any of the columns or the rows at the moment, so if we wanted to apply gutter to our grid we could do so with grid gap.

    00:24 Using grid gap like this is actually shorthand for both the row and the column gaps. If we look under the hood here, there's our shorthand being applied. If we wanted different values for the rows and columns we could pass separate values.

    00:43 Now, we have grid row gap of 10 pixels and grid column gap of 100 pixels. If we don't specify a second argument, grid column gap will be the same as grid row gap. Of course, if we wanted to we could specify grid row gap and grid column gap without using shorthand.

    01:00 Using grid gap, our gutter only applies to within the grid. If we wanted it on the outside as well, we could just use margin.

    Discuss

    Discuss