Home arrow Style Sheets arrow Using Auto Margins to Center DIVs with CSS
STYLE SHEETS

Using Auto Margins to Center DIVs with CSS


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.

Author Info:
By: Alejandro Gervasio
Rating: 5 stars5 stars5 stars5 stars5 stars / 1
April 02, 2009
TABLE OF CONTENTS:
  1. · Using Auto Margins to Center DIVs with CSS
  2. · Building a basic fixed layout with CSS auto margins
  3. · Adding CSS styles to a sample web document with some structural markup
  4. · Completing the web page layout

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Using Auto Margins to Center DIVs with CSS
(Page 1 of 4 )

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!


blog comments powered by Disqus
STYLE SHEETS ARTICLES

- CSS Combinators: Working with Child Combinat...
- CSS Combinators: Using General Siblings
- Intro to CSS Combinators
- CSS Semicircles and Web Page Headers
- Drawing Circular Shapes with CSS3 and Border...
- More CSS Pagination Link Templates
- CSS Pagination Links
- Animated CSS3 Image Gallery: Advanced Transi...
- CSS3 Animated Image Gallery: Transitions
- CSS3 Properties: Fixed Heights with box-sizi...
- CSS3 Properties: Altering Strokes and 3D Eff...
- CSS3 Properties: Text-Stroke
- CSS3 Transitions: Width and Height Properties
- Creating a Drop Down Menu in CSS3
- Intro to CSS Transitions

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials