html align text center code example

Example 1: html center text

<div style="text-align:center">Dieser Text wird zentriert.
<p>Ebenso dieser Paragraph.</p></div>

Example 2: css vertical center

/*Remove comment to become a better programmer. */
/* No Flexbox */
.parent {
  position: relative;
}
.child {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

/* With Flexbox */

.parent {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

Example 3: how to align text in html

<!-- Code by Scratchy -->
<!-- Twitter: @S_cratchy-->

<!-- Solution 1 -->
<p>
  This is some cool text in html, wow such cool text
</p>

<!-- Solution 2 -->
<font style="text-align:right;"> This text is on the right</font>
<font style="text-align:center;"> This text is in the center</font>
<font style="text-align:left;"> This text is on the left</font>

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 align text center

<p style="text-align: center;"> Center Align </p>