HTML/CSS What does height:auto do in CSS?

  • Thread starter Thread starter shivajikobardan
  • Start date Start date
  • Tags Tags
    Css
AI Thread Summary
The discussion centers on the practical implications of using height: auto versus height: 100% in CSS. Height: auto allows an element to adjust its height based on the content it contains, which is the default behavior for block elements like forms. The necessity of explicitly setting height: auto is questioned, as it is already the default value. However, if an element's height is changed to a specific value, reverting it back to auto may require JavaScript or more specific CSS selectors, including media queries. The conversation highlights a trend in modern web development to minimize JavaScript for styling purposes, favoring CSS solutions instead.
shivajikobardan
Messages
637
Reaction score
54
TL;DR Summary
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?
 
Technology news on Phys.org
You don't have to set height to auto because it is the default value for that property.

But if you set it to something else, it is possible that you would need to change it back to its default value with Javascript.
 
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.
 
  • Like
Likes jack action
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Replies
10
Views
2K
Replies
9
Views
2K
Replies
5
Views
2K
Replies
5
Views
2K
Replies
1
Views
2K
Replies
8
Views
2K
Replies
2
Views
1K
Replies
2
Views
2K
Replies
3
Views
2K
Replies
4
Views
1K
Back
Top