w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Is there a better way to horizontally align elements, than text-align: centre?

text-align: center (not centre) is your best bet. There are things you can do to prevent the items from breaking to a new line, such as setting a (max-)width on images inside this div based on media queries. But as far as aligning them in the center goes, just use text-align and if you want to break to a new line, a simple br will do the trick.

You said you played with margins. If you want to space elements out on the same row, keep using the margin property, but in addition to the text-align on the parent div.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.