default browser margins

Hey, is it recommended to utilise the margin that is on elements such as headings and paragraphs by default? I ask this because regarding resets, I see some use the wildcard selector to remove margin/padding from every element, and others not touch the margins at all. I’m a bit confused on the reasoning behind this so id appreciate any insight, thanks in advance.
26 Replies
Jochem
Jochem9mo ago
personal preference mostly. I like to leave them alone as much as possible, because they're well considered and half the time you're adding them back in further down the line anyway
snxxwyy
snxxwyyOP9mo ago
Ah got it. Would the fact they’re set in px affect responsiveness regarding users zooming in and changing their default font size though?
Jochem
Jochem9mo ago
I'm not sure honestly, but you'd have to test that anyway
snxxwyy
snxxwyyOP9mo ago
No worries, from your use of leaving them do they seem to do the trick for you?
Jochem
Jochem9mo ago
I mean, I don't feel the need to override, so yeah, I guess 🙂
snxxwyy
snxxwyyOP9mo ago
Alright cool, thank you for your input. And I guess if it ends up interfering with the responsiveness you could always re-define the default values in rem in your reset right?
Jochem
Jochem9mo ago
rem isn't magically responsive
snxxwyy
snxxwyyOP9mo ago
I understand, but it would accommodate the users preferences and scale the size of the margin up and down if they change their default browser font size right?
Jochem
Jochem9mo ago
it's a bit of a non-concern honestly. The margins and paddings are small, it's fine to define them with px. rem and em are for when you want some element of the design to scale with the font size. eh, depends on the situation
snxxwyy
snxxwyyOP9mo ago
Ah so rem and em are more for like svgs and stuff?
Jochem
Jochem9mo ago
rem and em are just not magic. I see a lot of people use rem and responsive in the same breath, and they're just not super related concepts
snxxwyy
snxxwyyOP9mo ago
Oh? What situations would and wouldn’t warrant that?
Jochem
Jochem9mo ago
if you set a height and width in rem, it will still not be responsive depends on if the padding really needs to grow or shrink along with the user's font size. Again, you need to test because there are no hard and fast rules
snxxwyy
snxxwyyOP9mo ago
Yeah that makes sense So setting a width and height in em/rem or px is essentially the same?
Jochem
Jochem9mo ago
for responsive design purposes, yes
Jochem
Jochem9mo ago
Kevin Powell
YouTube
Are you using the right CSS units?
There are a lot of different units that we can use when writing CSS, in this video I give some general rules of thumb of which ones are best suited for which situations. Zell's article on media queries: https://zellwk.com/blog/media-query-units/ Em vs. Rem: https://youtu.be/_-aDOAMmDHI Using clamp() for fonts: https://youtu.be/U9VF-4euyRo The ...
snxxwyy
snxxwyyOP9mo ago
In what other purposes would that not be the case? I’ll check that out, thanks
Jochem
Jochem9mo ago
all rem and em do is change the size so that it's dependent on the local or root font size. That's literally it. The one place you must use rem or em is when you're setting a font size, but other than that it shouldn't necessarily be the unit you go for if there's others that make more sense. anyway, I gotta run, so maybe someone else can answer any followups you have
snxxwyy
snxxwyyOP9mo ago
Alright no worries, thank you for your help!
ἔρως
ἔρως9mo ago
personally, i like using rems nearly everywhere for one simple reason: scaling this is probably a bad idea from an ux/ui design, but if someone has a bigger font size, i presume that it is someone that also has other issues - like issues finding where stuff is or issues reading long content so, if everything grows a little, i assume it is helpful this may or may not be what you want for your site, but it is something i wanted for the ones ive made
snxxwyy
snxxwyyOP9mo ago
that's what i was thinking when i queried it being set in px. The text would grow and since the space isn't growing everything would look clumped together eventually.
ἔρως
ἔρως9mo ago
the default margins onthe document won't do that don't worry also, i highly doubt that anyone increases the text size to the point where it causes very serious issues
snxxwyy
snxxwyyOP9mo ago
ah okay, thank you
ἔρως
ἔρως9mo ago
you're welcome
clevermissfox
clevermissfox9mo ago
Also if using grid or flex the margins no longer collapse so it looks like the default margin will double. I use flex/grid a lot so I do end up zeroing them since they’ll need to be adjusted anyway if collapsing margins are no longer merging
ἔρως
ἔρως9mo ago
oh, yeah, forgot about that
Want results from more Discord servers?
Add your server