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 6383197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:37:08+00:00 2026-05-25T02:37:08+00:00

To explain my problem, I’m trying to make a div wide enough to accommodate

  • 0

To explain my problem, I’m trying to make a div wide enough to accommodate a dynamically generated title without wrapping it, but the div also has other content, which I want to wrap.

In other words:

CSS:

.box {
    min-width:170px;
}

.box span.title {
    font-size:24px;
    white-space: nowrap;
}

.box span.text{
    font-size:10px;
    white-space: normal;
}

HTML:

<div class="box">
   <span class="title">Title on one line</span><br />
   <span class="text">This is the main body of text which I want to wrap as
           required and have no effect on the width of the div.</span>
</div>

However, this is causing the div to expand to be wide enough to contain the main body of text on one line, which I want to wrap. I’ve tried various arrangements for CSS and the putting them all inside container divs and the like but I can’t seem to get the box to be exactly wide enough to contain only the title without wrapping (but not less than the min width)

Is there any way to do this just in CSS? Note I don’t want to set a max width as this just causes it to become a static size again, as the main body of text is always going to be enough to hit the max width. I also can’t line break the body manually as it’s dynamically generated.

  • 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-25T02:37:08+00:00Added an answer on May 25, 2026 at 2:37 am

    Is this (jsFiddle) what you’re trying to accomplish?

    I just added display: table; to .box’s CSS. This expands the main div to the width of the title span but wraps the text span.

    Note: You can also set a constant width to prevent the div from expanding to the width of the window. This way it will still expand to the width of the title if it is larger than your constant width, but will not grow if the user drags out the window. In my example I added width: 100px; to demonstrate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It might sound unnecessary, but let me explain my problem first. Probably then it
Sorry for the vague title, as I really can't explain this problem succinctly. Basically
let me explain my problem. I have a mouseout event assigned to a div
I am having difficulty to explain this problem, but I will try anyway. I
let me try to explain my problem. I'm currently trying to develop a small
It is not easy to explain the problem without an image and without code.
[Sorry for long question but it is necessary to explain the problem] I am
Edited to better explain my problem I am trying to perform a zoom operation
I know this looks a bit long but i tried to explain the problem
I will explain problem with an example: There is two table in my database,

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.