Log In Registration

CSS Centralized Layout Container

  • Sharebar

If you’re new to CSS, you might be wondering why is it that when you create a container they all stick to the left side of the page:

This is the default layout, and years back when most people had very small screens, these left-side layouts sufficed.  These though, it is wise to stick to a centralized layout because people are using all kinds of screen sizes so it’s the recommended layout to use for easy browsing.

To achieve a centralized layout on CSS:

Your code should look a bit like this:

#container {
     margin: 0 auto;
     text-align: left;
     width: 1000px;
     position: relative;
}

‘Margin-zero-auto’ centralizes your #container, ‘text-align-left’ ensures that your content begins from the left side, ‘width’ controls the width of your container (this can also be set in percentage, which allows fluid width relative to the browser canvas), and ‘position-relative’ ensures that any div with the absolute position property is positioned relative to the container.

So you’ve got yourself something pretty solid with that.

Related posts:

  1. CSS Trick: Position Absolute Inside Relative
  2. Blog Theme’s Outline Layout Completed
  3. Driving Lesson #16 – More Cones + Reverse Parking
  4. How To Edit WordPress Login Page
  5. How To Make A Simple Website Using Adobe Dreamweaver
This entry was posted in Tutorials and tagged , , , , , , , , , , , , , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.
  • Support sabrinasabino.com!

No Comments

(Required)
(Required, will not be published)

CommentLuv badge

  • RSS Featured Software

  • Categories

  • Archives

  • About Me

    WYSIWYG! I'm a simple person trying to live the simplest life possible - it seems to be the most difficult thing to achieve! I'm an internet enthusiast and I've been a webmaster since early 2007. I like: blogging, developing sites using open source software, social media, computer games, '80s music, comedy & horror, animals, crunching on M&Ms peanut and Smarties!
More in Tutorials (35 of 78 articles)


Beginners of Cascading Stylsheets (CSS) might not know this trick that I'm about to share.  The day you find out about 'position: absolute' is the day you will feel like ...