Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to show div at the center of the page

    • 0
    • 2
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 800
    Comment on it

    Hello all,

    When we create our UI design of HTML page, and we want to put specific div at the center of the page, we can do that with the help of CSS (Cascading Style Sheet). we can set the width of the div to a certain pixel and set the margin attribute to 0 auto.

    Here is the code packet :

    In HTML:

    <!DOCTYPE html>
    <html>
    <head>
        <style>
            .centerAlign{
                width:80%;
                margin:0 auto;
            }
        </style>
    </head>
    <body>
    <div class="centerAlign"> 
    // Some content 
    </div>
    </body>
    </html>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: