Welcome to the Treehouse Community
Looking to learn something new?
Henrique Voni12,296 Points
Question about centering with margin:auto
I noticed that sometimes
margin: 0 auto doesn't center my element on the page. Are these the requirements for centering that way?
1) Must be a display:block element; 2) Must have a width value.
Are there more requirements or am i wrong?
Nathan Tallack22,158 Points
Yeah, you need a width. Try setting your width to 90%. Avoid a px value here because if your browser window is narrower then you will get the horizontal scroll bars.
Matthew Stanley1,071 Points
Always remember Nathan's advice, because having to scroll horizontally is Hell on Earth.