I have several same HTML elements going one after another:
<span>1</span>
<span>2</span>
<span>3</span>
I’m looking for the best way of adding space between the elements using CSS only
[no space] [1] [space 10px] [2] [space 10px] [3] [no space]
Additionally:
- Please write down browser compatibility of your receipts
I don’t want to use any additional HTML markup like
<span></span> <span></span> <span class="last_span"></span>
I don’t want to use tables.
I want the first and last span to be targeted automatically by CSS.
I don’t want to use JavaScript.
Optional requirement: last span can be not last child of the parent tag, but it will be the last span of the parent tag. Spans do
not have any other tags between them.
A good way to do it is this:
Every
spanpreceded by aspan(so, everyspanexcept the first) will havemargin-left: 10px.Here’s a more detailed answer to a similar question: Separators between elements without hacks