Style Sheets
  Home arrow Style Sheets arrow Using Auto Margins to Center DIVs with CSS
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
STYLE SHEETS

Using Auto Margins to Center DIVs with CSS
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2009-04-02

    Table of Contents:
  • Using Auto Margins to Center DIVs with CSS
  • Building a basic fixed layout with CSS auto margins
  • Adding CSS styles to a sample web document with some structural markup
  • Completing the web page layout

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Using Auto Margins to Center DIVs with CSS


    (Page 1 of 4 )

    If you’re a web designer searching for a comprehensive guide that shows you how to build centered web page layouts by using a few simple CSS styles and basic markup, look no further. Welcome to the third installment of a series that focuses on centering DIVs with CSS. By means of a hands-on approach, this series walks you through implementing some proven CSS-based techniques that will let you create different kinds of centered web document layouts in a truly painless way.

    Introduction

    Now that you know what this group of articles is about, it’s time to recall the topics that were discussed in the last tutorial. In that particular article I explained how to build a fully-centered web page layout by using the “text-align” CSS property, which you’ve probably utilized hundreds of times before.

    Speaking more specifically, this CSS-based technique relied heavily on the mentioned property for centering all of the main DIVs that composed the structure of the web page, by assigning a “text-align: center” declaration to the “body” element of the web document. Undoubtedly, this is one of the simplest approaches that can be used for constructing centered designs very quickly, since the procedure requires only a minimal background in style sheets. That’s all.

    However, as was stated in the beginning, there are a few other methods that can be utilized for building centered web page layouts. Most of them base their functionality on employing CSS margins. Yes, as you may have guessed, it’s possible to place a DIV in the middle of a web document by assigning the same values to its respective left and right margins.

    Therefore, in this third chapter of this series I’ll be explaining in a step-by-step fashion how to use CSS margins for building a liquid, centered web document layout. Then, once you’ve grasped the logic that drives this approach, I’ll show you how to use it with liquid designs.

    Now, with the preliminaries out of our way, it’s time to discover the real power of CSS margins for centering DIVs on a web page. Let’s get started!

    More Style Sheets Articles
    More By Alejandro Gervasio


       · This third part of the series demonstrates how to use CSS auto-margins for building...
     

    STYLE SHEETS ARTICLES

    - Image Replacement CSS Techniques
    - Using BlueTrip`s Success, Notice and Error C...
    - More Uses for the Thin and Caps CSS Classes ...
    - Styling Definition Lists with the BlueTrip C...
    - Styling Unordered and Ordered HTML Lists wit...
    - Using the BlueTrip CSS Framework`s Thin and ...
    - Adding Borders to Web Page Columns with Blue...
    - Introducing the BlueTrip CSS Framework
    - Using a Background Grid to Assist Web Page L...
    - Extending the Rule Of Thirds for Web Page La...
    - A Two-Column Web Page Layout Based on the Ru...
    - Using the Rule Of Thirds for Web Page Layout
    - Swapping Columns Using the Divine Ratio for ...
    - Using the Golden Ratio in Liquid Web Page De...
    - Fundamental Design Principles for Web Page L...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek