HTML & CSS · Middle · Question 56 of 75

How do you push the last item of a flex navbar to the far right?

.nav { display: flex; }
.nav .logout { margin-left: auto; }

Explanation

In flex layout auto margins take all remaining space in that direction. margin-inline-start: auto is the logical-property version that also works in RTL.

Further reading

Problem with a question

HTML & CSS · Middle · question 56

Test yourself

Take the HTML & CSS · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz