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

  • Home
  • SEARCH
  • 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 8658455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:46:20+00:00 2026-06-12T15:46:20+00:00

I have a span within another span where the child has no set width

  • 0

I have a span within another span where the child has no set width so the text is going onto a new line after just 1 or 2 words.

Here’s the code and a jsfiddle which will help to better see what I mean.

<span class="container">Lorem ipsum dolor
    <span class="child">Lorem ipsum dolor Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut risus enim, tincidunt ac tristique quis, vulputate sed nulla. Nam imperdiet imperdiet mollis. Vestibulum sed elit lorem, et luctus massa. Vivamus eleifend ante vel odio lacinia.
    </span>
</span>

css:

.container {
    width:auto;
    background-color:red;
    position:relative;
}

.child {
    position:absolute;
    top:35px;
    left:10px;
    max-width:500px;
    background-color:yellow;
    /*white-space:nowrap; This does not work because the text does not wrap after 500px */ 
}

http://jsfiddle.net/RRx6r/

What I ideally want to achieve is the child span expanding to a maximum of 500px depending on the quantity of text in it.

white-space:nowrap does not work because the line never breaks.

Any ideas?

  • 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-06-12T15:46:21+00:00Added an answer on June 12, 2026 at 3:46 pm

    add

    display:block;
    

    to either the .container, or to both the .container and the .child (depending on issues with your other css rules). Note that you need to set a max-width on the container as well, else it will grow to whatever space is available.

    See this Fiddle

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

Sidebar

Related Questions

I have my span tag: <span style=text-decoration:line-through > Hello World <a href=http://www.yahoo.com>Yahoo</a> </span> As
Is it ok to have a span tag within another span tag? I need
I have the following thats within a loop... echo <span class='srch-val'>.apply_filters( $value\n, $value).</span>; I
I have contenteditable span with a max-width setting that allows the user to enter
I have 1 span within a container div. I want the span floated to
I within my li element I have a link and some text contained within
I have a span @ positioned absolutely within an input to guide the user
I have a span that contains text that I would like to use. But
In my html I have a span of class dragHandle embedded within a li.
I have an html where i want to add another div within the description

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.