Add to Favorites

Floats and Horizontal Alignment

If you're like me, you know that aligning elements horizontally can be a huge pain. You can endlessly mess with widths, heights, margins and padding and never end up with elements that line up just right across all the browsers. Before you put yourself through the torture, try floats. Wrap your elements in one div and float each element left. This will align all your elements, even pesky block elements like divs.

Sometimes this simple fix can be just what you need. Imagine my surprise, after spending time trying to fix a page across multiple browsers, when I floated all the elements in question and it immediately started working.


Be the first to leave a comment on this post.

Leave a comment

To leave a comment, please log in / sign up