CSS CSS Basics Understanding Values and Units Percentages

Konrad Dziekonski
Konrad Dziekonski
7,797 Points

text-align: center



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?


1 Answer

Steven Parker
Steven Parker
203,207 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; }