A general question about flex. What’s the difference between “justify-content:” and “justify-self:”?
I’m thinking about “build a nutrition label” step 41. We first set p items to display as flex, and to justify its content with space-between. We then create a .right class, and set the justify-content property to “flex-end”. Am I right in assuming this is a specificity thing, where we are overriding p elements that have a .right class justify value? And that this wouldn’t work on, say, a h2 element if h2 isn’t set to display as flex? And that justify-self is for things wrapped in the flex element ( so if there is a… div or span element wrapped in the p elements, for instance…)?
First major difference is that justify-content belongs to flex containers where as justify-self belongs to grids.
justify-content applies to flex containers (the parents). It controls how the flex items are distributed along the axis and justify-self applies to individual grid items (the child). It controls how single item aligns within its grid cell.
Yes, you are right about the specificity part. .right has higher specificity and it overrides justify-content for paragraphs with that class.
Yea, this wouldn’t work for a h2 element unless and until it is a flex container i.e. display set to flex.
Once again, justify-self is not part of flex. It is a Grid layout property. You’ll be learning that in future lessons and then it will be more clear once you implement it.
Thank you for the answer! Because it is taught in the flex lesson, I assumed it was a flex property. But it still works with flex items? Or is setting them to ”justify-self” making them act as Grid items within the flex container?