/    Sign up×
Community /Pin to ProfileBookmark

What is auto do in margin:0 auto;?

I cant seem to exactly understand what auto does. I know it sometimes have an effect of centering objects. That’s about it. Thanks.

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@KravvitzAug 04.2006 — [b][For] Block-level, non-replaced elements in normal flow[/b]

[...]

If both 'margin-left' and 'margin-right' are 'auto', their computed values are equal.[/quote]

http://www.w3.org/TR/REC-CSS2/visudet.html#q6
Copy linkTweet thisAlerts:
@mark_yiehAug 04.2006 — margin: auto will automatically make all the margins to have the same value. If you didn't set a size for the tag that you are placing the margin: auto property, then there isn't going to be any visual difference. It does help to center a document, but only if the width property has been set. For example:

.body {width: 800px; margin: 0px, auto;}
×

Success!

Help @burnt1ce85 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...