What does height:auto do in CSS?

  • Context: HTML/CSS 
  • Thread starter Thread starter shivajikobardan
  • Start date Start date
  • Tags Tags
    Css
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 2K views
shivajikobardan
Messages
637
Reaction score
54
TL;DR
height:auto
https://stackoverflow.com/questions/15943009/difference-between-css-height-100-vs-height-auto
I read the accepted answer and it doesn’t make much sense to me in practical applications.

Here’s my codepen.
What does height:auto does here?

As per my research, height:auto fits content. Ie As much content, that much height.
Also height:auto is default for every block element and form is a block element, why is it necessary to add height:auto here?
 
Physics news on Phys.org
jack action said:
change it back to its default value with Javascript.
Or a selector with more specificity, or a media query. In 2022 we tend not to use JS for look-and-feel.
 
Reply
  • Like
Likes   Reactions: jack action