if its correct as -is, can you explain why we’d use text-align to center it horizontally instead of justify-content? Thanks
There is often more than one way to do something with CSS. The text-align
property is used to center content in a block element. It’s super easy to use and does the job just fine. Using justify-content
(and actually, I think you would use align-items
instead) requires at least setting the display to flex and changing the flex direction to column, and there might even be other changes required. So why do all of that when you can just use text-align
ok, only a few steps earlier it asks you to do so using justify-content as its a rule(?) youve already set to use flexbox, this was adjusting one which wasnt and thats the difference I wasnt grasping, the effect of text-align in one vs the other
" The CSS align-items
property sets the [align-self
(link) value on all direct children as a group. In Flexbox, it controls the alignment of items on the [Cross Axis(link). In Grid Layout, it controls the alignment of items on the Block Axis within their [grid area(link)."
thank you
I’d say when centering text text-align
is the perfect tool for the job. It is literally what it was created for.
Centering using flexbox or grid is usually used for centering elements, not just text inside elements. The address
element is already centered using flexbox on its parent container.
thanks Ill keep that in mind, I was incorrectly trying to use flexbox properties on a ruleset that was using grid layout, also apologies if my terminology is off this is my first week
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.