Design comparison
Solution retrospective
- should I in general set height and width of container elements or rather style the insides with margin, padding, gap arguments and let the browser calculate the width and height?
- feedback is greatly appreciated!
Community feedback
- @BernardusPHPosted over 1 year ago
Hey KAKUHD
I know you might hear this a lot and I'm sorry but it really depends on the item you are working on and what effect you want it to have to its children, sibling or its parents. The height part can be left to the browser to sort out mostly, except for specific scenarios because messing with height can be a headache
For example, responsiveness is my main reason for playing with width and height. Screen size can mess up your day so I play with
clamp
, which I highly recommend using as it can make things like responsive sizing easier especially when using on width.And there are other reasons like trying to fit things in a parent container or making things the same width or height then its understandable to play with width and height.
Margin and padding can help with movement and sizing but its sometimes unpredictable for example on inputs, padding just creates an annoying invisible wall that the words hide behind sometimes.
I would just recommend winging it and see what works for you.
Also here is a tip for your project:
Please don't use a div as a landmark without reason(like a framework). What I mean is, the DIRECT children of the body. There are a few landmarks like
- nav
- main
- footer
- aside etc.
For your project I would just replace the direct children of the body into main and footer respectfully. The reason for this is for the developers so we don't get easily lost in the code and also screen readers use the landmarks.
Marked as helpful0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord