<?xml version="1.0" encoding="utf-8"?>

CSS margin property for centering an element

CSS margin property for centering an element Bad Practice
CSS margin property for centering an element Best Practice

You can center elements, using the margin property. You take both individual margin-left and margin-right properties and set them to the auto value. What happens when you apply this value only to the left or right margin? The element is pushed to the opposite side of the container, while the left/right margin receives a large share of the unused horizontal space.

Top contributors

Joseph Angelo Todaro

Topics

From Lesson

Share

Improve your UX & Product skills with interactive courses that actually work