center
is mostly for centering text and is being deprecated in favor of text-align
and margin-*: auto
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/center
Why doesn’t html just have hcenter and vcenter tags or something?
HTML is a markup language, its purpose is to structure documents, while CSS can be seen as an additional layer that allows you to style and alter the layout of HTML documents. Because of this philosophy, it wouldn’t make any sense to have such tags.
I wasn’t expecting this to work, and yet it does: https://css-tricks.com/the-peculiar-magic-of-flexbox-and-auto-margins/
When Sam says, “that item will automatically extend its specified margin to occupy the extra space in the flex container,” the way my empty filing cabinet brain interprets that is like so:
Setting the margin property on a flex child will push the child away from that direction. Set
margin-left
toauto
, the child will push right. Setmargin-top
toauto
and the child will push to the bottom.[…]
Why is this useful to know? Well, I think there are a few moments where
justify-self
oralign-self
might not get you exactly what you want in a layout where using auto margins gives you that extra flexibility to fine-tune things.
Check your ad-blocker, some blocklists have blocked files.catbox.moe for some reason unknown to me.