Welcome to the Treehouse Community
Looking to learn something new?
Dani Ivanov10,732 Points
Centering links within a div
I've been working on a project of my own and I'd like to know this:
In this example http://jsfiddle.net/BDt6U/
If I apply the text-align: center property to the .linksWrapper a declaration, then the links will not center. However, If I apply the text-align center to the .linksWrapper, the links will center.
My logic, and I am probably wrong, is that I should apply the center property to the links themselves since I want the links to center, but I found out that this is not the case.
Tom Bedford15,645 Points
If you apply text-align center it to just the anchor tags then it will center text within each individual tag. If you set a large width for the anchor tags you can see how the text positioning works inside them. By applying the centering to the div you are centering the position all text (which includes the links) that are within that div. Even if they are centered in the div you can still align the text in each anchor tag separately.
If you have a set of links that you are displaying together it is common to organise them in a list.
I've edited the fiddle to illustrate the different aligning settings and show the list method.