Centering:
Centering an element requires setting a width that is less than 100%, using a proper document type and using the CSS property: margin: 0 auto; This is done in the CSS that styles the element. Example:
Example as an ID:
Code:
#selector_name{
width: 90%;
height: 600px; /* optional */
margin: 0 auto;
}
Example as a Class:
Code:
.selector_name {
width: 90%;
height: 600px; /* optional */
margin: 0 auto;
}
HTML for Class:
Code:
<div class="selector_name">Content here</div>
Example as an ID:
Code:
#selector_name {
width: 90%;
height: 600px; /* optional */
margin: 0 auto;
}
HTML for Class:
Code:
<div id="selector_name">Content here</div>
Bookmarks