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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:56:04+00:00 2026-06-08T22:56:04+00:00

I have the following code: <div id=container> <div id=div1>Div 1</div> <div id=div2>Div 2</div> </div>

  • 0

I have the following code:

<div id="container">
    <div id="div1">Div 1</div>
    <div id="div2">Div 2</div>
</div>

I want to be able to have #box1 and #box2 one next to the other inside the container. Container is centered

  • 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-08T22:56:06+00:00Added an answer on June 8, 2026 at 10:56 pm

    This will center the container, and have the two divs within it centered, while separating the styles from the actual content:

    HTML:

    <div id="container">
        <div>Div 1</div>
        <div>Div 2</div>
    </div>
    

    CSS:

    #container > div
    {
        display: inline-block;
        border: solid 1px #000;
    }
    #container
    {
        border: solid 1px #ff0000;
        text-align: center;
        margin: 0px auto;
        width: 40%;
    }   
    

    Working example:

    http://jsfiddle.net/JLjjK/

    2017 Update:

    Flexbox is becoming much more commonplace. Here’s a way to achieve similar results with Flexbox:

    HTML:

    <div class="outer">
      <div>1</div>
      <div>2</div>
    </div>
    

    CSS:

    .outer {
      border: 1px solid #000;
      display:flex;
      justify-content: center;
      padding: 3px;
    }
    .outer > div {
      border: 1px solid #000;
      margin:2px;
    }
    

    Example: https://jsfiddle.net/pb61a1cj/1/

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

Sidebar

Related Questions

I have the following HTML code / structure: <div id=container> <div id=div1>text</div> <div id=div2>more
I have following code <div id=main> <div id=one> </div> <div id=two> </div> <div id=three>
I have the following code <div id=container> <div id=_01>1° item</div> <div id=_02>2° item</div> <div
I have following code snipped in _Layout.cshtml <div id=sub-navig-container> @RenderSection(subNavig) </div> <div id=text-content> @RenderBody()
I have the following code: <div id=container> <div id=top>TOP TEXT </div> <div id=middle>MIDDLE TEXT
I have the following code. <div class=container> <input type=hidden name=id value=123 class=id /> <div
I have the following code: <div id=object-container> <object data=some-file.swf> <param name=src value=some-file.swf /> </object>
Have the following html code: <div id=container> <div id=container2> ... </div> </div> and the
Let's say you have the following chunk of code: <div id=container> <someelement>This is any
I have the following HTML code: <div class=container> <span class=red></span> <span class=hot></span> </div> On

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.