CSS CSS Basics The Box Model Margins

Why is the footer centered?


I can't help but notice that the footer is also centered after adding "margin: auto" to the primary-content and secondary-content class rule.

How does the footer get affected if the footer is in a class all of its own?

Is it because it has this code? .primary-content, .main-header, .main-footer { text-align: center;

Although, wouldn't it still be pushed to the side of the web page?

Try taking .main-footer out of that line of code and on a line by itself, if you don't want it centered.

2 Answers

Matthew Stanley
Matthew Stanley
1,071 Points

It was already centered before. The element takes up the entire width of the page. When the text is centered, it's also centered on the page, since the footer spans the page. Change the background color, and you'll notice the width of the footer element.

Nick Yoho
Nick Yoho
6,957 Points

Is your footer wrapped inside another tag in your html?