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
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.

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