html center h1 code example

Example 1: html h1 left align

<h1 style="text-align:center">Titulo 1</h1>
<h2 style="text-align:left">Titulo 2</h2>
<h3 style="text-align:right">Titulo 3</h3>
<h4 style="text-align:justify">Titulo 4</h4>
<p>...</p>

Example 2: how to center an h1 in html

<style>
h1 {
  text-align: center;
}

h2 {
  text-align: left;
}

h3 {
  text-align: right;
}
</style>
/* or you can do inlne
<h1 align="center">Example</h1>

Example 3: center header html

<h1 align="center">This is heading 1</h1>

Example 4: html move h1 to center

div{
  height: 400px;
  width: 800px;
  background: red;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

Tags:

Html Example