CSS CSS Basics Understanding Values and Units Percentages

Konrad Dziekonski
Konrad Dziekonski
7,707 Points

text-align: center

http://w.trhou.se/ym0iq4vu0l

Hi!

If You cvould check out style.css file on the very bottom i'm enquiring about this part

.primary-content { text-align: center; }

.primary-content, .secondary-content { width: 60%; }

no matter which of these inputs goes first both primary and secondary content gets width of 60% of the screen and the alignment is to the left. Is it important which input goes first? Are the first ones suppesed to override the following ones, ot the opposite or how does it work? :) and why the primary content is not centered?

Thanks!

1 Answer

Steven Parker
Steven Parker
177,727 Points

The text inside of the "primary-content" container is centered within that container. That's what "text-align: center" does.

What you probably want to do is center that container in the window. That can be done with auto margins:

.primary-content { margin: 0 auto; }