Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Design centering a footer when margin: 0 auto; is not working Reply To: centering a footer when margin: 0 auto; is not working

#248876
Beverleyh
Participant

The footer element is a block level element by default, so it spans 100% of its container (unless any other styles are applied to alter that). Something that is 100% width of the container is already centered per se, so auto-ing the left and right margin will have no visual effect. It seems more likely that you’re trying to centre the elements that are inside the footer sotext-align:center; might be more appropriate here. However, the success of text-align:center; depends on what’s inside that you’re trying to centre, and those element’s defined styles. We’d really need to see what you’re working with to be able to offer specific help. If the previous suggestion doesn’t work, provide a reduced demo in CodePen and we can take a look.