center element code example

Example 1: css align items vertical center

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

Example 2: mettre une image au milieu css

IMG.displayed {
    display: block;
    margin-left: auto;
    margin-right: auto }
 ...
<IMG class="displayed" src="..." alt="...">

Example 3: centering css elements

// add to the parent element
.parent {
	display: grid;
    place-items: center;
}

Example 4: how to center a div element

/*ADD MARGIN auto to left and right*/
.box1{
    width:80%;
    margin:0 auto;
}

Example 5: center css elements

body{
  display: grid;
  place-items: center;
}

Example 6: how to put element in center in html

p {
  text-align: center;
}