Centering our Page

Steps to center a page:

  • have or make a container and give it a width.
HTMLCSS
<div class=”container”>.container {
width: 800px;
}
</div>
  • set margin-left and right to auto, so that the width is automatically placed and there will be a margin on the left and on the right which will be exactly the same size.
	width: 800px;
	margin-left: auto;
	margin-right: auto;
  • better yet, use the margin shorthand. Top and bottom=0, and left and right=auto:
	margin: 0 auto;
  • you can even put a percentage on the width, to adjust to different sizes of screens:
	width: 80%;

This entry was posted in Web Developer Course and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *