Tip of the day: margin-left: auto

Posted by on Jun 11, 2013 in Tip | 2 Comments

learned a really simple, but nifty trick. I’m sure we all know about margin: 0 auto;  right? That will align a block level element perfectly centered in whatever it’s contained in. Wellll, did you know that you can apply that to specific margin directions? I was trying to figure out how to align an element to the right without floating it. I discovered this wonderful Stack Overflow post and my eyes were opened: margin-left: auto; margin-right: 0;  would do exactly what I was looking for.


Oh snap


  1. Peter Briers
    July 22, 2013

    Great tip!

    • Nathaniel
      July 22, 2013

      Thanks, Peter!


Leave a Reply