Cancel last margin in horizontal element listing ?

I would like your advice on this.
I need to display inline unknown numbers of elements in a width fixed container. (let’s say 940px)
There is a gap between these elements of 20px (with a margin-right)
Problem is the last element in line jumps to the bottom even if there is visually enought place, because of that margin.

As I dont know the number of elements, I can’t play with .alpha/.omega css classes, or nth-child css rules…

A simple trick I use it to set a negative margin on the parent element, the same size as the gutter. So in your case, you should set a margin-right of -20px to your UL (if it has no fixed width). Thus the right margin of the last element of each line will fit into this space.

As far as I tested this, it works fine in all major browsers, but there may be some cases where it doesn’t.

displayinline said
A simple trick I use it to set a negative margin on the parent element, the same size as the gutter. So in your case, you should set a margin-right of -20px to your UL (if it has no fixed width). Thus the right margin of the last element of each line will fit into this space.

As far as I tested this, it works fine in all major browsers, but there may be some cases where it doesn’t.

displayinline said
A simple trick I use it to set a negative margin on the parent element, the same size as the gutter. So in your case, you should set a margin-right of -20px to your UL (if it has no fixed width). Thus the right margin of the last element of each line will fit into this space.

As far as I tested this, it works fine in all major browsers, but there may be some cases where it doesn’t.