How to right align div elements with CSS?

Spread the love

To right align div elements with CSS, we use flexbox.

For instance, we write

<div style="display: flex; justify-content: flex-end">
  <div>I'm on the right</div>
</div>

to make the outer div a flex container with display: flex.

And we align the elements inside it to the right with justify-content: flex-end.

Leave a Reply

Your email address will not be published. Required fields are marked *