Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Why is text-align center used to center a footer?

Why is text-align: center used to center a footer when a footer isnt text, but a block element? logically shouldn't (text-align) align well, text. If I look up the text align it says its used to center texts, so I'm a bit confused.

1 Answer

Remember, block elements go the entire width of the page. So the text-align property will put the Hello on the right side of that block. It's not the footer that's being aligned. It's the text inside.

<!DOCTYPE html>
<html>
  <head>
    <style>
      footer {
        text-align: right;
     } 
    </style>
  </head>

  <body>
    <footer>Hello</footer>
  </body>
</html>