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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:54:42+00:00 2026-05-26T19:54:42+00:00

How do I put the two divs side by side? What if I have

  • 0

How do I put the two divs side by side? What if I have more than 2 divs and I want to put them all side by side? I found that if they are canvas, they are automatically placed side by side. This is not true for divs.

In additional, how come the button’s value doesn’t change the text on the button? I was expecting “Commit” to show up but it didn’t.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>HTML5 Test</title>
<script type="text/javascript">
  function draw () {

    var displayHeight = 200;
    var displayWidth = 100;
    var container = document.getElementById("container");

    var Div = {
        elemOne  : CreateRectDivElement (displayWidth/2,displayHeight/10*8),
        elemTwo  : CreateRectDivElement (displayWidth/2,displayHeight/10*8),
        buttonCommit: CreateButtonElement (displayWidth,displayHeight/10*2)
    };

     Div.buttonCommit.type="button";
     Div.buttonCommit.value="Commit";
     Div.elemOne.style.border = '1px solid black';
     Div.elemTwo.style.border = '1px solid black';

    container.appendChild (Div.buttonCommit);
    container.appendChild (document.createElement("br"));
    container.appendChild (Div.elemOne);
    container.appendChild (Div.elemTwo);


  }

  function CreateRectCanvasElement(width, height)
  {
    var canvas = document.createElement('canvas');
    canvas.style.position = 'relative';
    canvas.style.border = '1px solid black';

    canvas.style.width = width + 'px';
    canvas.style.height= height + 'px';


    return canvas;
  }

  function CreateButtonElement(width, height)
  {
    var element = document.createElement('button');
    element.style.width = width + 'px';
    element.style.height = height + 'px';

    return element;
  }

  function CreateDivElement()
  {
    var div = document.createElement('div');
    div.style.position = 'absolute';
    return div;
  }

  function CreateRectDivElement (width, height)
  {
    var div = document.createElement('div');
    div.style.width = width + 'px';
    div.style.height= height + 'px';

    return div;
  }
</script>
</head>

<body onload="draw()">
<div id="container"></div>
</body>
</html>
  • 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-26T19:54:43+00:00Added an answer on May 26, 2026 at 7:54 pm

    DIV issue

    Use display: inline-block; or float: left; in the style.

     Div.elemOne.style.display = 'inline-block';
     Div.elemTwo.style.display = 'inline-block';
    

    Button issue

    The value is not in every browser the caption of the button. Use the inner html/text for the caption, just like you do for links <a href="...">Link text</a>.

    <button value="Commit"></button>
    <br />
    <button>Commit</button>
    

    Button Sample
    http://jsfiddle.net/t9etS/

    Fixed sample from the comments
    http://jsfiddle.net/APqgz/2/

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

Sidebar

Related Questions

I have managed to put two divs side by side using a <div class=clear></div>
I have two divs floated left so that they appear next to each other.
I have two divs one inside of the other, now i want to put
I'm trying to put two divs on the right side of parent div one
I have two buttons and two divs(I put one above another). I made info
I have a TD that contains two divs. The first div contains text and
On my page, I put two divs: nav and contents. Inside nav, I have
I want to put two float:right'ing divs ontop of eachother. I've tried position:relative; top:-HEIGHTpx;
I have a div that i want to apply two backgrounds to it. Basically
i have multilingual asp.net site. there is a masterpage and default.aspx. I put two

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.