Most pages today are laid out using layers (divs), so the problem of aligning the site to the center of the browser window is reduced to the task of centering the layer that determines the width of the visible area of the page. For it to be positioned in the middle of the window, it is necessary to set the appropriate settings for its parent element, or for this block itself.
It is necessary
Basic knowledge of HTML and CSS languages
Instructions
Step 1
Place the layer that you want to position in the center of the window, between the opening and closing parts of the center tag, if you want to do just using HTML (HyperText Markup Language - "hypertext markup language"). We will assume that the parent of the layer that defines the page borders is the body of this page. The simplest version of the HTML code using the center tag in this case might look like this:
Center page
page text
Step 2
If you want to use CSS (Cascading Style Sheets) to center the page, use auto-sizing of the padding from the borders of the browser window. The margin sizes in CSS are determined by the margin parameter. Remove the center tags from the previous sample and add a margin parameter with a value of 0 auto to the style attribute of the layer that defines the page width:
Center page
page text
Step 3
Of course, the style definition can be taken out of the style attribute and placed in an external file or in the head of the document (between the and tags). In this case, the same code will look like this:
Center page
#pageFrame {
width: 700px;
height: 400px;
background: # 0BB;
margin: 0 auto;
}
page text