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

Jonathan Buford
Jonathan Buford
2,065 Points

Why does adding display: block; padding: 10px 15px; result in moving the name and link to center?

Wow. I really feel like I should know this. I usually make things harder than they are but I've been on this for 3 days and have just started reverse engineering Guil's code in the zip file so I could at least learn something. Not knowing where to start and then having questions turn into more questions...I've been studying CSS and HTML for 9 months now and it has me worried;( These items were already showing on their own line before display: block.

Ugh. I feel like even my questions are not good, but I need you guys!

3 Answers

Padding and Display properties are two different aspects so I dont think must be centering an object, https://www.w3schools.com/cssref/playit.asp?filename=playcss_display&preval=block follow this link to know more about DISPLAY.

The padding doesn't necessarily have anything to do with it; it's the "display: block;"

Jesse Sandate
Jesse Sandate
985 Points

yeah exactly... The display property with a value of block makes the a-tags, which are normally inline elements, into block size. Thats why each link's hover area is the entire width of the viewport, essentially that is what is centering the text in the menu.