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 CSS Layout Basics CSS Layout Project Creating and Styling the Layout Containers

how could he use 'text-align' property to center the block elements?

at 2:22 he write .name a, .main-nav a { text-align: center; display: block; padding: 10px 15px; }

I looked up at https://developer.mozilla.org/en-US/docs/Web/CSS/text-align it says text-align does not control the alignment of block elements So how did he use text-align: center; given that he set tag a elements to be block?

1 Answer

Kieran Barker
Kieran Barker
15,028 Points

You can use it to center-align the text inside a block-level element.

If you read carefully, the MDN Web Docs say β€œThe text-align CSS property describes how inline content like text is aligned in its parent block element”.

The <a> element was defined as a block-level element, but the text inside it is still inline.

thanks man!