I adjusted the width of a paragraph to make it less stretched out horizontally and more compact. However, when I attempted to center align the text within the paragraph using text-align: center;
, only the direction of the paragraph was centered.
The challenge lies in getting the actual text content centered properly. I experimented with applying text-align: center;
to both the <div>
and the p
, but without success.
Perhaps the width property is not necessary? Any guidance would be greatly appreciated.
.content {
margin: 3cm auto;
text-align: center;
}
.content p {
line-height: normal;
font-size: 16px;
}
#text {
width: 500px;
}
<div class="content">
<div id="text">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam rutrum ex quis hendrerit sagittis. Proin fringilla id sapien suscipit hendrerit. Integer sed diam nec turpis fringilla facilisis id non nulla.</p>
</div>
</div>