If you want to center a text within a <div> element using CSS, then you can make use of the text-align attributes value set as center..
Example:
css code:
<div class="div-eg">Some Text</div>
html code:
.div-eg {
width:400px;
height: 200px;
text-align: center;
background: #eee;
border:1px solid #222
}
Output:
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!