center in html code example

Example 1: css align center

//HTML
<div class="parent">
	<span>Hello World</span>
</div>

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

Example 2: center p html

<p style="text-align: center">this is centered</p>

Example 3: align in the middle of page html

.centered {
  position: fixed;
  top: 50%;
  left: 50%;
  /* bring your own prefixes */
  transform: translate(-50%, -50%);
}

Example 4: html how to center text

<p style="text-align:center;">Centered paragraph.</p>

Example 5: how to center text in html

text-align: center;

Example 6: html center tag

<center>
	<p>This is centered</p>
</center>

Tags:

Css Example