Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Michael Pashkov
UX Design Techdegree Student 11,350 PointsAlternate sticky footer method
Hi guys! Question is If instead of class I use tag - Sticky method doesn't work. Why?
<footer class="main-footer">
Doesn't work
body {
display: flex;
flex-direction: column;
min-height: 100vh;
}
footer {
margin-top: auto;
}
Works
body {
display: flex;
flex-direction: column;
min-height: 100vh;
}
.main-footer {
margin-top: auto;
}
3 Answers

Steven Parker
216,865 PointsIt works identically for me both ways. Perhaps you had a typo when trying the tag which does not show here?

meghana Joshi
4,596 PointsNever mind I got the answer here :
janatoc on Apr 25, 2017 Hi, I had the same issue. It's because footer has the margin already set in the base.css file --> .main-footer {margin-top: 30px; } As class selector (.main-footer) has higher specificity than element selector (footer), it will overrule your footer {margin-top: auto;} style. You have to set .main-footer {margin-top: auto;} that should work.

Michael Pashkov
UX Design Techdegree Student 11,350 PointsThanks meghana Joshi

meghana Joshi
4,596 PointsI have the same problem. The footer tag does not work while the class name works. there is no typo
Michael Pashkov
UX Design Techdegree Student 11,350 PointsMichael Pashkov
UX Design Techdegree Student 11,350 PointsThanks for testing. I was thinking that way, but wasn't sure.