How to make a div center align in HTML [duplicate]

Web Technologies Web Development 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating
_x000D_ _x000D_ Possible Duplicate: How to horizontally center a div? One simple way to make an object centered in HTML is using align='center', but it's not working for a div. I tried: style='text-align:center'; style='left:50%'; I even true a center tag
But I can't make my target div to be center.

Posted on 16 Aug 2022, this text provides information on Web Development related to Web Technologies. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago
_x000D_ _x000D_ _x000D_ _x000D_ _x000D_ _x000D_ Center_x000D_ _x000D_ _x000D_ _x000D_
_x000D_
This DIV is centered
_x000D_
_x000D_ _x000D_ _x000D_ _x000D_ _x000D_ Tested and worked in IE, Firefox, Chrome, Safari and Opera. I did not test IE6. The outer text-align is needed for IE. Other browsers (and IE9?) will work when you give the DIV margin (left and right) value of auto. Margin "0 auto" is a shorthand for margin "0 auto 0 auto" (top right bottom left). Note: the text is also centered inside the inner DIV, if you want it to remain on the left side just specify text-align: left; for the inner DIV. Edit: IE 6, 7, 8 and 9 running on the Standards Mode will work with margins set to auto.

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

Important Web Technologies Links