Categories
CSS

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

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