TJS TJS - 10 months ago 43
CSS Question

What is the best practice for center aligning inline elements within a div?

For example if I have a parent div and 5 images I want to have centered within that div with a little margin around the images.

iiz iiz
Answer Source

Use the text-align css value on the container:

div {
text-align: center;

And apply the margin to each of the images inside:

div img {
margin: 5px;