TJS TJS - 14 days ago 6
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

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;
}
Comments