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

How to get your header in the centre of the page?

Its just not working! this is the code i have been using:

padding-top:10px; padding-bottom:10px; padding-left:1px; padding-right:1px;

   margin-right: 5px;
   margin-left: 5px;
   margin-top:5px;
   margin-bottom:5px;
   border-radius: 25px;

   text-align: centre;

It goes to slightly to the right and not the centre?

6 Answers

Are you british by any chance? text-align: center;

I'm not sure if this is correct or not, can you just do margin: auto; ?

Hi James!

In order to center any element horizontally margin left and right should be equal to auto. Taking your notes as an example, it looks like you want a margin top and bottom to be equal to 5px. Try this:

'''css margin: 5px auto; '''

The value of padding shouldn't change this behaviour, so you can freely play with it. Let me know if it works.

Good luck! Miriam

Hi James!

In order to center any element horizontally margin left and right should be equal to auto. Taking your notes as an example, it looks like you want a margin top and bottom to be equal to 5px. Try this:

'''css margin: 5px auto; '''

The value of padding shouldn't change this behaviour, so you can freely play with it. Let me know if it works.

Good luck! Miriam

margin: 5px 5px;
border-radius: 25px;
text-align: center; 

This is what would be better to use as the margin 5px 5px would mean top bottom left and right and as for the text align i had this trouble its the spelling trying center over centre.

Thanks everyone!