Horizontally center a div element in a div tag

Horizontally center a div element in a div tag

Home Forums CSS Horizontally center a div element in a div tag

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #33240
    SEO hacker
    Participant

    How can i make horizontally center (center alignment)  a <div> within another div tag using css. I am trying to create a form. here is the code:

    <div id=”stylo” style=”width: 100%;”>
    <div class=”inner”><form> </form></div>
    </div>

    #33259
    HARPAL SINGH
    Keymaster

    Simply set the width of the outer DIV tag then set the width of the inner <DIV> and set its left right margin to auto. here is the complete CSS :

    <style>

    #style{display:block; width:100%}

    .inner{display:block; margin:0 auto; width:80%; }

    </style>

    Replace 80% with the width of the inner DIV.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.