iamnards
iamnards

Reputation: 217

CSS: how to align text content horizontally-centered and vertically-centered?

how can i align text content inside div horizonally-centered and vertically-centered?

   <div style="height: 300px;">
     <p>Envision various details for your big day with help from our photo catalog, which features images filtered by category. See actual works from suppliers to help you make decisions.</p>
   </div>

Upvotes: 0

Views: 332

Answers (1)

Mr. Alien
Mr. Alien

Reputation: 157294

You need to use display: table-cell; and vertical-align: middle; properties with text-align: center; as well to align the text vertically and horizontally centered

Demo

div {
    border: 1px solid #f00;
    display: table-cell;
    text-align: center;
    vertical-align: middle
}

Upvotes: 2

Related Questions