Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk2 min

How to Put Three Elements Side by Side

Wrap the spans in a parent with display:flex for a controlled row. For ordinary text, spans are already inline and wrap naturally.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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 gap to control space between the items.
  • Use align-items to align items across the row, and justify-content to distribute free space along it.
  • If all three items should have equal widths, apply flex: 1 to 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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

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.

Avoid these common layout mistakes

  • Apply display: flex to the common parent, not separately to each span; the parent controls the layout of its direct children.
  • Do not set flex-direction: column if the goal is a horizontal row; that stacks items vertically.
  • display: inline-block on 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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.