CSS Center – This short tutorial and snippet will show how to center with CSS

CSS Center HTML

<body>
  <div class="centerMe">
    <!-- Put centered content here -->
  </div>
</body>

CSS Center

This CSS centering includes styling that may be required for older versions of ie. To center an element in CSS be sure to include the elements width.  For more dynamic sites, you may want to use jQuery width to get the width of the element.

.centerMe {
     width: 960px;
     margin-left: auto;
     margin-right: auto;
     text-align: left; /* for ie */
}
 
/* for ie */
body {
  text-align: center;
 }

CSS center an element such as a div, page, or image.

LEAVE A REPLY

Please enter your comment!
Please enter your name here