How to right-align div elements with CSS?

Spread the love

Sometimes, we want to right-align div elements with CSS.

In this article, we’ll look at how to right-align div elements with CSS.

How to right-align div elements with CSS?

To right-align div elements with CSS, we can set the justify-content property to flex-end.

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 and align its contents to the right with

display: flex; justify-content: flex-end

Conclusion

To right-align div elements with CSS, we can set the justify-content property to flex-end.

Leave a Reply

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