How to center-align items

svg viewer

Use the following steps to center-align text in the middle of a div container.

  1. Create a div container.
  2. Insert the button tag, image tag, or text you want to enter.
  3. In the CSS for the div, set text-align to center.

The button and all the contents within the div should now be center aligned.

Below is a working code example that can help you better understand the concept:

Note: The <center> tag has been discontinued in HTML 5 and can no longer be used to center-align the text.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved