Enhancing Table Layout
border-spacing
is a CSS property that can be used to create space between table cells. However, if you want to apply this property to a span
, you must set its parent element's display to table
and the span
itself to table-cell
.
div{
border-spacing: 10px;
display: table
}
span{
border: 1px solid red;
display: table-cell
}
<div>
<span>a</span>
<span>b</span>
</div>
Adjusting Margins
Alternatively, you can add a margin
to create spacing between elements. Keep in mind the margin on the last element, which may need to be adjusted.
.spacer{
border: 1px solid gray;
margin-right: 20px;
}
/*REM: Remove margin on last element*/
.spacer:last-of-type{
margin-right: 0
}
<span class='spacer'>a</span>
<span class='spacer'>b</span>
<b>c</b>