In html, what can we write in the code to bring the content of my web page in the center ?? I have tried to write the code within "center" tag and "/center" but it's not working. so any other alternatives ??


1 Answer 1


You simply limit the width of a block element and define automatic margins or if you want to center the text just use text-align. You can use a CSS class or style the element directly.

<!DOCTYPE html>
      .center {
        margin: auto;
        width: 60%;
        border: 1px solid #000000;
      p {
        text-align: center;
    <div class="center">
      <p>Hello World!</p>

Not the answer you're looking for? Browse other questions tagged or ask your own question.