#I remember that one time is was said, that there are times you should not use height. When?

3 messages · Page 1 of 1 (latest)

fleet dragon
#

I remember that one time is was said, that there are times you should not use height.Could someone please remind me when?

related, here my button text, got pushed down, why did that happen? and when should I not use height?

    margin: 25px 0 35px 0;
    width: 120px;
    height: 42px;

    background-color: white;
    border: none;
    border-radius: 5px;
    
    padding: 15px 30px;

    font-size: 16px;
    font-size: medium;
    font-family: inherit;
}```
rocky ferry
#

Well, as a general rule you should just allow your content to flow... things in html are designed to grow as needed.

The only time I use height is when I'm trying to make something full-screen. So say you want a footer that "sticks" to the bottom no matter how much content there is in the main body.

flint fjord
#

Like Bill said, as a rule of thumb you should avoid heights period.

Even when using a fixed position Footer you may want to just let the Footer be the height of its content plus its padding (although sometimes you need to know the height to give the exact size as a margin or padding to elements ubderneath) And his example of full screen is the only time I use heights , if my section needs to be 100dvh but has very little content and i know theres no risk of overflow, that's when I use. If needed I'll add a min-height: 100dvh to the body if my content doesn't fill the screen and I need to center it.