CSS Property Value How to - text-align: center;








Question

We would like to know how to text-align: center;.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
nav div {<!--  w w  w  .  j a  va2s  .  c o m-->
  width: 33.3%;
  float: left;
}

#one {
  background: yellow;
}

#two {
  text-align: center;
  background: lime;
}

#three {
  text-align: right;
  background: aqua;
}
</style>
</head>
<body>
  <nav>
    <div id="one">
      <button>One</button>
    </div>
    <div id="two">
      <button>Two</button>
    </div>
    <div id="three">
      <button>Three</button>
    </div>
  </nav>
</body>
</html>

The code above is rendered as follows: