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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:37:28+00:00 2026-05-13T17:37:28+00:00

I have 2 nested divs inside outer one, which has width:100%. Both nested divs

  • 0

I have 2 nested divs inside outer one, which has width:100%. Both nested divs should be in one line and first should get it size from it’s contents:

<div id="#outer" style="width:100%; border:1px">
  <div id="#inner1" style="border:1px; display:inline">
    inner div 1. Some text...
  </div>
  <div id="#inner2" style="width:100%????; border:1px; display:inline">
    inner div 2...
  </div>
</div>

Question is how to make #inner2 div to get rest of the horizontal space if width of the #inner1 div is not specified and depends on what it is inside?

P.S. All styles are in separate classes in my case, here I putted CSS into style attributes just for simplification.

I want result to work in IE7+ and FF 3.6

In more details for me it looks like this:

 <style type="text/css">
.captionText
{
 float:left;
} 

.captionLine
{
 height: 1px;
 background-color:black;
 margin: 0px;
 margin-left: 5px;
 margin-top: 5px;
 border: 0px;
 padding: 0px;
 padding-top: 1px;
}
 </style>
<table style="width:300px;">
<caption width="100%">
     <div class="captionText">Some text</div>
     <div class="captionLine"> </div>
</caption>
     <tr>
           <td>something</td>
     </tr>
</table>

Here is the image of what I want:
Image of what I want

  • 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-13T17:37:28+00:00Added an answer on May 13, 2026 at 5:37 pm

    The mysterious overflow: hidden; is your friend here. It stops elements adjacent to floats from extending behind the float — I think that’s the layout you’re looking for.

    Here’s some slightly edited HTML: I don’t think you can have # characters in your ids:

    <div id="outer">
        <div id="inner1">
            inner div 1. Some text...
        </div>
        <div id="inner2">
            inner div 2...
        </div>
    </div>
    

    And here’s the CSS to achieve the layout you want.

    (I put in additional CSS for IE 6 with HTML conditional comments. I just noticed you didn’t actually need it to work in IE 6 too, but if you fancy being nice to the IE 6 users out there…)

    <style type="text/css">
    #outer {
        overflow: hidden;/* Makes #outer contain its floated children */
        width: 100%;
    
        /* Colours and borders for illustration purposes */
        border: solid 3px #666;
        background: #ddd;
    }
    
    #inner1 {
        float: left;/* Make this div as wide as its contents */
    
        /* Colours and borders for illustration purposes */
        border: solid 3px #c00;
        background: #fdd;
    }
    
    #inner2 {
        overflow: hidden;/* Make this div take up the rest of the horizontal space, and no more */
    
        /* Colours and borders for illustration purposes */
        border: solid 3px #00c;
        background: #ddf;
    }
    </style>
    
    <!--[if lte IE 6]>
    <style type="text/css">
    #inner2 {
        zoom: 1;/* Make this div take up the rest of the horizontal space, and no more, in IE 6 */
    }
    
    #inner1 {
        margin-right: -3px;/* Fix the 3-pixel gap that the previous rule introduces. (Shit like this is why web developers hate IE 6.) */
    }
    </style>
    <![endif]-->
    

    Tested and working in IE 6, 7, and 8; Firefox 3.5; and Chrome 4.

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

Sidebar

Ask A Question

Stats

  • Questions 400k
  • Answers 400k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The term you are looking for is "file extension". The… May 15, 2026 at 4:14 am
  • Editorial Team
    Editorial Team added an answer According to the ExtJS team, JSON is easier and faster… May 15, 2026 at 4:14 am
  • Editorial Team
    Editorial Team added an answer Zend_Db can only return what the MySQL adapter can return.… May 15, 2026 at 4:14 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.