How To Center A Div

Table of contents:

How To Center A Div
How To Center A Div

Video: How To Center A Div

Video: How To Center A Div
Video: 4 Quickest Ways to Center Div with CSS 2024, November
Anonim

Modern page markup standards do not prohibit the use of table layout, however, layered layout, in fact, has become a mandatory standard when creating sites. In addition to the obvious advantages, the supplanting of table layout has brought some new problems, big and small. One of them is the horizontal alignment of the block structure in the page. Let's look at a couple of practical ways to set the layer to the center of the page width.

How to center a div
How to center a div

Necessary

Basic knowledge of HTML

Instructions

Step 1

One of the options for solving the problem of aligning a layer (DIV block) to the center of the open page window is bypassed only using HTML (HyperText Markup Language). You need to put the block inside the tag. The simplest page code, laid out in this way, may look, for example, like this:

Aligning a DIV to the center

Step 2

Another option uses CSS (Cascading Style Sheets). In the style of the aligned layer, set the autodetection of the amount of offset from the window borders. The code of such a page in its simplest form can be, for example, like this:

Aligning a DIV to the center

Recommended: