Search code examples
htmllayoutcenter

2 divs centered in html page


I try to make a better layout of my webpage, so I want to place two divs in the center of my html page. I do not have access to my css file. Is it possible to center two divs on one page in html code without css?

This is my code:

<div style="width: 100%;">
<div style="; width: 100%;">
<h1 style="text-align: center;">This is Web Page Main tit</h1>

<div style="position: relative;
   float: left;
   left: 0px;
   width: 470px;
   height: 470px;
   margin: 0 auto;
   background-color: #828282">
<div><strong>Main Menu</strong></div>
  </div>

<div style="position: relative;
   float: left;
   margin: 0 auto;
   left: 0px;
   width: 470px;
   height: 470px;
   background-color: #828282">
<p>oke and Managerial Tutorials</p>
</div>

</div>
<div style="background-color: #b5dcb3; clear: both;">Here text</div>
</div>


Solution

  • For two <div>'s next to each other aligned in the center of your page:

    <center>
    <div>
    <div style="display: inline-block">
    <!-- div 1 contents -->    
    </div>
    <div style="display: inline-block">
    <!-- div 2 contents -->
    </div>
    </div>
    </center>