Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6850387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:07:05+00:00 2026-05-27T01:07:05+00:00

I have a <div> with hard-coded width. Inside the <div> are several hundred <span>

  • 0

I have a <div> with hard-coded width. Inside the <div> are several hundred <span> tags. Can I wrap the spans so that line spacing is correct and wrapping is between spans? I use word-wrap: break-word and it looks a mess.

Here is pseudo code.

span {
  margin: 2px;
  border: 1px dotted #cccccc;
  padding: 4px 10px 4px 10px; 
    }
div {
  padding: 5px;
  margin: 5px;
  border: 1px solid #cccccc;
  width: 800px;
  word-wrap: break-word;
}

<div>
  <span>stuff</span>
  <span>more stuff</span>
  <span>even more stuff</span>
  .
  .
  .
</div>

Thanks!

EDIT for clarification: There should be multiple spans on each line, and wrapping should be between spans.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:07:06+00:00Added an answer on May 27, 2026 at 1:07 am

    EDIT (2017): Flexbox with wrap display: flex; flex-wrap: wrap is compatible with IE10+ (and Android 4.4+) and will allow versatile alignments both horizontally (justified, aligned to the left or right, space-around, centered) and vertically (align-items) with also versatile spacing between lines (align-content… if an height is set, in general).
    Bonus: no ~4px whitespace between items to take care of as with inline-block. You do pretty much what you want: no gutter, flex: 1 1 auto or padding: 1rem for example
    Cheatsheet for Flexbox on CSS Tricks
    /EDIT

    Span doesn’t seem very semantic, maybe use an unordered list?

    If I understood well your problem, you want as many span per line that’ll fit but no span begininng on a line and finishing in another line?
    Then the following fiddle: http://jsfiddle.net/MRR6P/ will do the trick. Try

    span {
      line-height: 1.8;
      word-wrap: normal;
      display: inline-block;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have an inner div that sites inside different sized container divs,
I have a div with overflow:hidden , inside which I show a phone number
I have a div with two nested divs inside, the (float:left) one is the
I have a Div with five float divs inside: var div=document.createElement(div); div.className=cssDivNino; var divFolio=document.createElement(div);
So I have this Div that has a roll over effect on it where
I have a bunch of elements like the following: <div class=droppableP id=s-NSW style=width:78px; height:63px;
Inside of an asp.net mvc partial view, I have an Ajax form that posts
I have a lot of messages, and raw HTML that I hard code in
I have a webpage with a layer that appears which has height 500px. Inside
I have a DIV #Message_PHPVARABLE that ought to appear at the bottom of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.