how to center div on page code example

Example 1: center a div in css

.container {
  display: flex;
  justify-content: center;
  align-items: center;
}

Example 2: how to put container in center of page

#container
{
    width: 400px;
    margin-left: auto;
    margin-right: auto;
}

Example 3: text vertical align css

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style type="text/css">
      div {
        display: table-cell;
        width: 250px;
        height: 200px;
        vertical-align: middle;
      }
    </style>
  </head>
  <body>
    <div>Vertically aligned text</div>
  </body>
</html>

Example 4: css center text

/* To center text, you need to use text-align. */

.centerText {
  text-align: center; /* This puts the text into the center of the 
  screen. */
}

/* There are also other things that you can use in text-align:
left, right, and justify. Left and right make the test align to the
right or left of the screen, while justify makes the text align both
sides by spreading out spaces between some words and squishing others. */

Example 5: how to center text in css

.class {
	text-align: center;
}

Example 6: how to put container in center of page

div.InSkinAlignCenter {
margin: 0 auto;
}

Tags:

Html Example