Skip to content Skip to sidebar Skip to footer

How Do I Center A Container In My Html/css?

I have developed a website as part of my assignment. As I am new to html/css I could not figure some problems out of my code. The assignment specifications says that the screen siz

Solution 1:

Jsfiddle: http://jsfiddle.net/2gtsK/show/

Removed width from body, Added margin:0 auto to #box

margin:0 auto is same as:

margin-top: 0;
margin-right: auto;
margin-bottom: 0;
margin-left: auto;

.

body
{
    height: 750px;
    margin: 2px;
    padding: 2px;
}


#box 
{
    width: 1000px;
    margin: 0 auto;
    height:100%;
    border:1px solid #8D8D8D;
}

Solution 2:

You can wrap it by another div and set that div's text-align:center;

Post a Comment for "How Do I Center A Container In My Html/css?"