Horizontal and Vertical centered div

Discussion in 'Web Design, HTML And CSS' started by webwss, May 19, 2009.

  1. webwss

    webwss New Member

    Joined:
    May 19, 2009
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Can anybody share code for Horizontal and Vertical centered div as I am not able to get it.
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,336
    Likes Received:
    377
    Trophy Points:
    83
    Try

    HTML:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <style>
    div.album {
    padding-top:25%;
    height:50%; 
    width:100%; 
    background-color: green; 
    text-align:center;
    vertical-align:middle;
    }
    </style>
    </HEAD>
    <BODY>
    <div class="album">
    This is some text
    </div> 
    </BODY>
    </HTML>
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice