Simulating border-collapse in lists (no tables)

Enrique picture Enrique · Apr 21, 2011 · Viewed 43.3k times · Source

I have always the same problem, when I have 2 adjacent elements with borders, the borders are merged. With tables we have the border-collapse property for solving this.

I've tried omiting the border from one of the sides, but that works only for elements in the middle, the first and final element will miss a border.

Does somebody know a solution for list elements for example?

Answer

Frederick picture Frederick · Dec 7, 2011

Here's how I solved it: add a margin-left/-top of -1px to each li element. Then the borders really collapse without any tricks.