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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:00:08+00:00 2026-05-17T23:00:08+00:00

I have two divs placed inside a larger div. Each one of these two

  • 0

I have two divs placed inside a larger div. Each one of these two divs contains dynamically generated content and thus their heights vary, so I cannot know which one of the two will be taller. The parent div they are placed in has a 1px border and I would like to have 1px line between these divs as well, so that the line extends all the way down to the bottom of the parent div which adjusts itself based on the heights of the child divs. This is much easier to understand in the following picture:

div explanation

I have tried setting the child divs to a height of 100%, but that does not seem to be working. How can I accomplish this effect? (This also needs to work in IE6)

  • 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-17T23:00:09+00:00Added an answer on May 17, 2026 at 11:00 pm

    Well, this is relatively easy, if all you want is a single border extending to the full height of the tallest element (in this case the tallest div), albeit my solution doesn’t really address the potential equal heights issue (if you wanted the background-color of each div to extend to the full-height of the tallest element. It does, though, satisfy your request for the full-height single border:

      #left,
      #right {
        width: 40%; /* adjust to taste */
        float: left;
        padding: 1em; /* adjust to taste */
      }
      #left {
        border-right: 4px solid #000; /* adjust to taste */
      }
      #right {
        border-left: 4px solid #000;
        margin-left: -4px; /* the negative width of the border */
      }
    

    JS Bin Demo.


    Edited to address my misunderstanding/mis-reading of the question.

    This approach is kind of a hack, but is achievable using the same mark-up as in the previous demo, but more complex CSS:

      #left,
      #right {
        width: 40%;
        float: left;
        padding: 1em;
      }
      #left {
        border-right: 4px solid #000;
      }
      #right {
        border-left: 4px solid #000;
        margin-left: -4px; /* the negative width of the border */
      }
    
      #right p,
      #left p {
        border-left: 1px solid #ccc;
        border-right: 1px solid #ccc;
        margin: 0;
        padding: 0 0.5em 1em 0.5em;
      }
    
      #right p:first-child,
      #left p:first-child {
        padding-top 1em;
        border-top: 1px solid #ccc;
      }
    
      #right p:last-child,
      #left p:last-child {
        border-bottom: 1px solid #ccc;
      }
    

    Demo at JS Bin.

    This won’t be cross-browser friendly, though, IE (for certain) is likely to have problems with, at least, the :last-child pseudo-selector, so a JavaScript solution might be better for you in this instance. Although there is a more simple option to wrap the inner divs (in this case the #left and #right divs) in another div:

    <div id="wrap">
        <div id="left">
            <div class="innerWrap">
                <!-- content -->
            </div>
        </div>
        <div id="right">
            <div class="innerWrap">
                <!-- content -->
            </div>
        </div>
    </div>
    

    Which can be used with the css:

      #left,
      #right {
        width: 40%;
        float: left;
        padding: 1em;
      }
      #left {
        border-right: 4px solid #000;
      }
      #right {
        border-left: 4px solid #000;
        margin-left: -4px; /* the negative width of the border */
      }
    
      div.innerWrap {
        border: 1px solid #000;
      }
    

    Demo at JS Bin

    But, while that’s more cross-browser friendly, it does start a descent into the madness that is divitis.

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

Sidebar

Related Questions

I have a div with two nested divs inside, the (float:left) one is the
I have two divs. One of them contains an input field the other a
I have a container div that holds two internal divs; both should take 100%
Suppose I have two DIVs on my page. <body> <div id=d1></div> <div id=d2></div> </body>
I have two divs floated left so that they appear next to each other.
On my page, I put two divs: nav and contents. Inside nav, I have
I have two divs and two separate links that triggers slideDown and slideUp for
I have two applications written in Java that communicate with each other using XML
I have two classes, and want to include a static instance of one class
I have two threads, one needs to poll a bunch of separate static resources

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.