center html page code example

Example 1: center p html

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

Example 2: align in the middle of page html

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

Example 3: centering in html

<style>
  element
  {
    text-align: center;
  }
</style>
-------------------------------------------------------------------------------
style.css
element
{
	text-align: center;
}

Example 4: align center html

<!-- use the center tag -->
<center>
  <!-- your code -->
</center>

Tags:

Css Example