Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Create blocks which have a gutter between them without using flexbox

Hi folks,

I have been trying to create the small news blocks in the below link without having to use flexbox, but didn't manage to,

http://www.bypasswebdevelopment.com/chepping/news.html

Does anyone know a way of doing it so that I can manage to have a gutter in between them only?

Daniele

1 Answer

you can do this. please see the example below. if its not what you are looking for let me know.

HTML

<ul>
    <li>first</li>
    <li>second</li>
    <li>third</li>
    <li>fourth</li>
    <li>fifth</li>
</ul>

CSS:

ul{
    list-style: none;
}
li{
    display: inline-block;
    background-color: lightblue;
    padding: 25px;
    margin-right: 10px;
    cursor: pointer;
}

the key here is using the display: inline-block, and margin-right properties. That is what will give you a horizontal list item with a "gutter" in this case it's 10px margin to the right of each list item.