We Recommend

CSS: The Definitive Guide CSS: The Definitive Guide
Provides you with a comprehensive guide to CSS implementation, along with a thorough review of all aspects of CSS 2.1. Updated to cover Internet Explorer 7, Microsoft's vastly improved browser, this new edition includes content on positioning, text wrapping (nowrap), lists and generated content, table layout, user interface, paged media, and more.


Posted By

Dydric on 03/10/08


Tagged

div center align


Versions (?)


Who likes this?

2 people have marked this snippet as a favorite

SmpleJohn
basicmagic


Center Div


Published in: CSS 


  1. <html>
  2. <head>
  3. <title>Center</title>
  4.  
  5. <style type="text/css">
  6. body{background:red;}
  7.  
  8. div#centered {
  9. background: white;
  10. position: absolute;
  11. width: 700px;
  12. height: 300px;
  13. left: 50%;
  14. top: 50%;
  15. margin-left: -350px;
  16. margin-top: -150px;}
  17. </style>
  18.  
  19. </head>
  20.  
  21. <body>
  22. <div id="centered">This div is centered</div>
  23. </body>
  24. </html>

Report this snippet 

You need to login to post a comment.