To arrange three spans as a controlled horizontal group, wrap them in a parent and set that parent to display: flex. Flex items line up in a row by default, and gap adds consistent spacing. If the spans are simply words or short text fragments in a sentence, you usually need no layout CSS: spans are inline by default.
Use Flexbox for a deliberate row
Give the three spans one shared parent, then make that parent a flex container:
<div class="row">
<span>First</span>
<span>Second</span>
<span>Third</span>
</div>
.row {
display: flex;
gap: 1rem;
}
Setting display: flex makes the parent a flex container; its direct children become flex items. The default direction is a row in the usual horizontal writing mode, so the spans appear side by side. See the MDN display reference and MDN Flexbox guide.
Choose spacing, alignment, and widths only as needed
- Use
gapto control space between the items. - Use
align-itemsto align items across the row, andjustify-contentto distribute free space along it. - If all three items should have equal widths, apply
flex: 1to each span. A basic side-by-side row does not need explicit widths.
When ordinary inline flow is enough
A span is normally an inline element. Adjacent spans in ordinary text flow stay on the same line when there is room and wrap naturally when they run out of space. This is usually the right choice for text fragments within a sentence; use Flexbox when the spans form a designed group that needs controlled spacing, alignment, or sizing. MDN explains block and inline layout in normal flow and the inline formatting context.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →#1 Best Overall
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
Decide what should happen on narrow screens
Flex items can shrink to fit by default. If the row should continue onto another line when its container gets too narrow, allow wrapping:
.row {
display: flex;
flex-wrap: wrap;
gap: 1rem;
}
Check the result at the actual container width. If the items must remain on one line, decide how their shrinking or possible overflow should work rather than assuming that a row will always fit.
Quick Recap
Best Value
Rank #4
Rank #2
Avoid these common layout mistakes
- Apply
display: flexto the common parent, not separately to each span; the parent controls the layout of its direct children. - Do not set
flex-direction: columnif the goal is a horizontal row; that stacks items vertically. display: inline-blockon each span is another option when inline flow with block-like sizing is needed, but spaces or newlines in the markup can create visible gaps. Flexbox provides more direct control over spacing.- If the content is genuinely tabular data, use table elements and their semantics instead of making spans imitate a table.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




