MDN self-hosted library · e01.org

`<center>` HTML centered text element

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

html
<center>
  This text will be centered.
  <p>So will this paragraph.</p>
</center>
html
<div class="center">
  This text will be centered.
  <p>So will this paragraph.</p>
</div>
css
.center {
  text-align: center;
}
html
<p class="center">
  This line will be centered.<br />
  And so will this line.
</p>
css
.center {
  text-align: center;
}