What's the deal with height: auto?

  Рет қаралды 119,466

Kevin Powell

Kevin Powell

Күн бұрын

Пікірлер: 155
@CodingNuggets
@CodingNuggets 3 жыл бұрын
Love when you cover anything CSS. I feel like I level up a little with each video. Thanks Kevin!
@kaanergunlu7836
@kaanergunlu7836 3 жыл бұрын
Good to know that I'm not alone :))
@jeevanprakash5482
@jeevanprakash5482 2 жыл бұрын
@@kaanergunlu7836 bro but without using height how do i set my div's a particular height?
@volodymyr2187
@volodymyr2187 2 жыл бұрын
@@jeevanprakash5482 Use paddings or set width / height in pixels. The first thing is commonly used in dynamic divs, which can change their height. And setting size in pixels is used for divs, which should be of a fixed size in any circumstances.
@adithyas6863
@adithyas6863 3 жыл бұрын
Ever since I've subscribed, it seems I am getting more and more better at CSS, please keep this up! RESPECT 100
@TKYasser
@TKYasser 3 жыл бұрын
Daamn, I'm sure you are better with CSS than the CSS creator himself xD
@modelshipwrights
@modelshipwrights 3 жыл бұрын
As usual I sort of know this but it's great to have it all confirmed and clarified - and also as usual (shouldn't be surprised by now) learnt some stuff I didn't know. Great stuff Kevin - keep 'em coming!
@levelasian1608
@levelasian1608 3 жыл бұрын
Hey Kevin, great video! It would be great to see that video about the behavior of height/ width: auto in a Flexbox/ grid context !!!
@jeevanprakash5482
@jeevanprakash5482 2 жыл бұрын
bro but without using height how do i set my div's a particular height?
@louisgamor
@louisgamor 3 жыл бұрын
Kevin is undeniably the BEST. He's like the Boyka in the CSS Ring 😍
@elahhaz1047
@elahhaz1047 3 жыл бұрын
Thanks for making these videos, very good at explaining what properties are and what they do, with simple examples .. too many makes videos are focused on a design goal and what (multiple) css properties to use for that, rather than what individual property does, those gets complex by default and harder to wrap your head around, why they get the result that they do. So Thank You!
@KevinPowell
@KevinPowell 3 жыл бұрын
Thanks for the kind words, really glad that you like my approach with these!
@somnvm37
@somnvm37 3 жыл бұрын
Questoin of the day: When percentages are counted from body size (body of the element) And when from the size of parent element. Usually that's not a problem, I just change display, but it's impoertant to know
@mohan9285
@mohan9285 3 жыл бұрын
You simplify the complex topics and makes very easy to understand :)
@OmniscientIgnorance
@OmniscientIgnorance 3 жыл бұрын
You really are the CSS king! Love your videos so much.
@Minu_Shalom
@Minu_Shalom 3 жыл бұрын
Hi Kevin! Thank you for this perfectly explained topic. I would be excited to watch a video from you about how to set a border with a radius and linear-gradient for a form input element. Keep up your excellent work :)
@ragnarlothbrook8117
@ragnarlothbrook8117 3 жыл бұрын
Useful stuff. I really dig this kind of short and 'to the point' vids you make.
@otmanm4095
@otmanm4095 3 жыл бұрын
I really love these kind of videos. Really thanks for all the content.
@KevinPowell
@KevinPowell 3 жыл бұрын
glad you like my content :D
@venkatmani7167
@venkatmani7167 3 жыл бұрын
It is really wonderful to see your explanation which will clear lot of questions around min-height and height.
@PatrikKulisek
@PatrikKulisek 3 жыл бұрын
A lot of people could get the impression that 'height' is useless, but some years ago when responsive websites wasn't a thing it was acually used a lot for layouts. Today it is widely used in styling of printed documents when you know what dimensions of 'paper' are.
@antjeplatte144
@antjeplatte144 2 жыл бұрын
I looked in a lot of sites to understand that, but here I found the answer :-) Next time, I will look in your channel first!
@ne9835
@ne9835 3 жыл бұрын
Thanks! I was running into some problem with heights, thanks for clearing things up for me!
@KevinPowell
@KevinPowell 3 жыл бұрын
Awesome, glad that you're enjoying my content.
@resty1672
@resty1672 3 жыл бұрын
Always get indepth pro tips from your channel,big thank!
@matrixdeterminant3629
@matrixdeterminant3629 3 жыл бұрын
Thanks Kevin!!! Your videos are extremely helpful!
@fahimmahmud3115
@fahimmahmud3115 3 жыл бұрын
Hi Kevin, first a big big big thank you for everything! Then, your line when you showed that the body is actually the area with all the contents and not the entire viewport was a eye-opener for me. I have always thought that the whole browser window was the body because setting the background-color to body would fill up the whole viewport. But you said that it overflows with that border example. This helped me with one of my problem with centering an element.
@abdillahsyafiq
@abdillahsyafiq 3 жыл бұрын
I just discovered your channel and now I'm limiting the video I watch from your channel to prevent overwhelming new css knowledge.
@KevinPowell
@KevinPowell 3 жыл бұрын
Haha, welcome aboard!
@VasilyPavlik
@VasilyPavlik 3 жыл бұрын
Excellent. Very useful for beginners and not only for them. Kevin, your hair has "height: auto" after quarantine :)
@KevinPowell
@KevinPowell 3 жыл бұрын
haha, totally. I think this is my last video before my haircut, lol.
@benzflynn
@benzflynn 3 жыл бұрын
*TWO CLARIFICATIONS:* *1. Width of **_block elements_** defaults to 100%. Width of **_inline elements_** defaults to auto. Height of elements always default to auto. Yet this doesn't mean you can **_always_** leave out any explicit assignment to them and expect them to render as 100% or auto anyway.* Because all websites today are responsive, an element whose width/height was left to default to auto may not render as such _because another width/height assignment inherited from a smaller screen size is automatically applied._ For example, the primary (i.e. mobile) CSS assigned to an element containing both a logo and logotype may be set to width: 100%. Without assigning this element a width at higher screen sizes, we still get the full screen width for this element - regardless of having it within a flexbox and having enough screen width for a navbar as well. To overwrite this "inherited" width/height value, we have to *expressly assign* _width/height: auto;_ in the @media code for this element at the larger screen size. The only place to _safely_ leave out assignment of width or height is in elements like _body_ or higher-level container elements where you can clearly see that things won't change with device size. *2. Always assign sizing to at least one dimension of a container element for an image whose element is not dimensioned.* Images are not like text which have a specific (or default) font-size which always gives text a set size. Images need a box of defined size before they can start to render. So if you intend using auto width/height on a container for images, be sure to put a width or height in your element. Since images usually need to be able to expand or shrink with screen size/orientation, it is easier in practice to dimension the containing element for the image and make the image width say 100% of this.
@yousif2712
@yousif2712 3 жыл бұрын
Great video! Keep the pink background next time please, easier on the eyes haha
@WojciechKobus
@WojciechKobus 3 жыл бұрын
You're doing a good job. Thanx for input.
@sebacamposdev
@sebacamposdev 3 жыл бұрын
thanks for the video. And yeah this video needs a part 2 with grid and flexbox
@SudeeptoDutta
@SudeeptoDutta 3 жыл бұрын
Hi Kevin. Can you make a video on table styling ? How to manage table cells width for uneven cells in header and body of the table ? Also the best way to set a height on table.
@KevinPowell
@KevinPowell 3 жыл бұрын
I hate tables, lol. I'll have to build up some courage to work on that :D
@SudeeptoDutta
@SudeeptoDutta 3 жыл бұрын
@@KevinPowell Haha. I hope that day comes soon 😄
@delulu6969
@delulu6969 3 жыл бұрын
I use colspan attribute on . Another project, I used grid, the css might get messy but you have a lot of control. At times, I feel like wanting to give up and make everything divs. Just my 2 cents.
@SudeeptoDutta
@SudeeptoDutta 3 жыл бұрын
@@delulu6969 Thanks for the suggestions.
@1998Hagis
@1998Hagis 3 жыл бұрын
You could show the mix of min-height: 100px; and max-height:100%; That is a great connections!
@ali-celebi
@ali-celebi 3 жыл бұрын
Great explanation! Quality content as usual :)
@diegoraffa4324
@diegoraffa4324 3 жыл бұрын
Hi Kevin! You are awesome! Looking forward your live on Scrimba and your Sass course in future.😁
@hopeofglory8108
@hopeofglory8108 3 жыл бұрын
Great video :) Would be nice to have a little codepen for this to play around with now, want to experiment with combos of height: auto on the body, etc!
@LorenHelgeson
@LorenHelgeson 3 жыл бұрын
I rarely use a fixed height. I liken it's valid usability back to the old days when designs were table based, and as a transition from those layouts to the modern fluidity.
@tomengelmann7272
@tomengelmann7272 3 жыл бұрын
I recently had some projects where max height was pretty useful. Think its rarely used but also powerful
@DrHappybone
@DrHappybone 3 жыл бұрын
That was really well explained, dude!
@KevinPowell
@KevinPowell 3 жыл бұрын
Thanks!
@SnSungod7
@SnSungod7 3 жыл бұрын
Thank you that really helped me clear lot of my doubts
@guillermoandradaFSD
@guillermoandradaFSD 3 жыл бұрын
It was easy before this video but you made it easier that time... Txs a lot
@theshredguitarist25
@theshredguitarist25 3 жыл бұрын
1:54 so helpful!
@twanasoftwareengineer1754
@twanasoftwareengineer1754 3 жыл бұрын
" Percentage of height is always percentage of the parent " ❤
@lestherxm
@lestherxm Жыл бұрын
Finally, I'm able to don't overflow the text on my containers, lol
@TheLuckyyy13
@TheLuckyyy13 3 жыл бұрын
Can you do a video on images? Like how to know beforehand how an image will look on a site, sizes, how to adjust which part of an image to show, responsive images etc.
@jayjohn3634
@jayjohn3634 3 жыл бұрын
Hey man, I am loving the videos!
@mikehenry01
@mikehenry01 3 жыл бұрын
This was great, but I was hoping you would've touched on the problems with using height:100% and the criteria required to make it work. Frankly, I'm stumped. My scenario: In addition to the element in question that I want to be height:100%, I have its direct parent, grandparent (there are no other intervening HTML elements), AND elements all set to height:100%, but it's not working. Ugh. I'm baffled. I feel like I'm missing something super simple....
@SUKI12809
@SUKI12809 3 жыл бұрын
Thanks you, new knowledge about CSS.
@80Vikram
@80Vikram 2 жыл бұрын
Cool hairstyle Kevin, who is your barber ?
@linh92nguyen53
@linh92nguyen53 3 жыл бұрын
so touching for an excellent video
@TristanGrimaux
@TristanGrimaux 3 жыл бұрын
"And we can see that we have that red border there, that's my body". Best line ever
@theartofwarren
@theartofwarren 3 жыл бұрын
Nice bite-size tidbit-thanks!
@venkatanagasai1579
@venkatanagasai1579 3 жыл бұрын
Sure this video gonna help me. Thanks sir..
@jamaluddin9158
@jamaluddin9158 3 жыл бұрын
Great informative videos kevin! I had a question on height in percentage. Does it refer to the height of the parent's content or content+padding+border and does box-sizing on parent affect that? I probably can test it out myself but I'm feeling lazy right now and also I would like your stance on it 😅
@procrastinator24
@procrastinator24 2 жыл бұрын
great video, thank you so much!
@Aabara_ka_dabara
@Aabara_ka_dabara Жыл бұрын
thankyou for this video. it really helped me to understand this
@johanjong7208
@johanjong7208 3 жыл бұрын
Hey Kevin, height can be essential when dealing with CLS. By the way, it would be nice if you could tell us how you deal with CLS problems.
@fah199990
@fah199990 3 жыл бұрын
I love css !! And i like you video
@itallovidal9383
@itallovidal9383 3 жыл бұрын
I would like to see a video of you explaining how to deal with height in general and why we cannot use % in heigh like we use in width. I struggle so much with this * Have not watched this video you posted yet
@KevinPowell
@KevinPowell 3 жыл бұрын
It might answer most of your questions about it :)
@justnevergiveup6761
@justnevergiveup6761 2 жыл бұрын
You're the best, Thanks.
@TytusDubel
@TytusDubel 3 жыл бұрын
thank You Kevin
@vivekv4250
@vivekv4250 3 жыл бұрын
Love your videos.. love from India
@mushfiqursorol6667
@mushfiqursorol6667 3 жыл бұрын
Sir Your Very Good Explainer When You Covered Something Hurd Things Be Come Esay And Simple Thank You Sir
@pavankumarvangala2548
@pavankumarvangala2548 3 жыл бұрын
Hi Kevin , Can you please make a video on Display options like flex, grid , inline-flex etc.. Thanks in advance
@venkatesh2788
@venkatesh2788 3 жыл бұрын
Please make SEO full course with projects
@avananana
@avananana 3 жыл бұрын
CSS is one of those things that are just filled with stupid inconsistencies just because it makes sense in a single situation. My god.
@hnccox
@hnccox 3 жыл бұрын
From now on, I am going to set the body always to a min-height of 100vh
@quickcodingtuts
@quickcodingtuts 3 жыл бұрын
Also you can't do transitions from a certain height to auto, which kinda sucks :/
@KevinPowell
@KevinPowell 3 жыл бұрын
Yes! And yeah, it's annoying, but it's because the content controls it, and any change to the viewport can change the height of the element, so the browser doesn't know how tall 'auto' is without first rendering it.
@fentFloyd
@fentFloyd Жыл бұрын
Very nice!
@shahbazkhalid6950
@shahbazkhalid6950 2 жыл бұрын
Kindly makes videos on these topics Vanilla JS , Bootstrap 5, Gradients & functions in CSS3 and when to use gradients and function,
@M25962
@M25962 2 жыл бұрын
Thanks for your work Kevin. Q: How can I center vertically an icon inside a container? I recently had to do this for some homework but I feel like I hard coded it because had to be super specific on the numbers I set.
@kapall3021
@kapall3021 2 жыл бұрын
im new too but u can put .container{ display: flex; align-items: center; }
@sxmvp
@sxmvp 2 жыл бұрын
Maybe a dumb question, but how would you go about centering something vertically if you don't have a set height size?
@lambo-ca
@lambo-ca 3 жыл бұрын
Thanks man.
@yuli3873
@yuli3873 Жыл бұрын
1:06 can someone throw some insight regarding why does that happen? I mean, the border seems to indicate where the body ends, but the background kinds of "overflow" it. Why is that? Wouldn't the background be limited itself to the border boundings?
@samithraniroshana4089
@samithraniroshana4089 3 жыл бұрын
Very very very useful ❤
@truedivan
@truedivan 3 жыл бұрын
Thank you!)
@vasilemidrigan50
@vasilemidrigan50 3 жыл бұрын
Thanks a lot!!!
@brianjett1446
@brianjett1446 2 жыл бұрын
What is the difference between max-hight and min-hight?
@awekeningbro1207
@awekeningbro1207 3 жыл бұрын
isn't 'auto' the default value of height?
@RubberDuckCoding
@RubberDuckCoding 2 жыл бұрын
VERY NICE!
@PC-tk7uv
@PC-tk7uv 3 жыл бұрын
whats the diffence between height auto and not setting the height at all
@mohitpandit3041
@mohitpandit3041 2 жыл бұрын
Thanks for explain it.. But no need to set height : auto. By default every elements have height auto
@misterhtmlcss
@misterhtmlcss 3 жыл бұрын
Perfect for those riders that we add e.g. announcing version 1.x.x. click here to learn more. I can now add that in and it'll appear whenever there is content. This is also great for forms where you might have a tool tip. Great timing actually because there is no tool tips on our app and I'm building them today and this is the perfect rule for what I have planned.
@KarimShalapy
@KarimShalapy 3 жыл бұрын
Heights have the same rules for ?
@kunited9
@kunited9 3 жыл бұрын
Great explanation
@KevinPowell
@KevinPowell 3 жыл бұрын
Glad you enjoyed it
@mdtajbirhossain8228
@mdtajbirhossain8228 3 жыл бұрын
Is there any different between auto and fit-content?
@kallekula9202
@kallekula9202 3 жыл бұрын
Then what's the different between heigh auto and height fit-content?
@nj5195
@nj5195 3 жыл бұрын
Can you please give an example of a horizontal card blog with text content and thumbnail width:650px and height:500px? I can't do it to be responsive.
@onesandzeroes
@onesandzeroes 3 жыл бұрын
Is there a difference between setting height to auto, and not setting it at all? Because from what I see height:auto is just the default behaviour.
@arthurdoomer
@arthurdoomer 3 жыл бұрын
.yourHair { auto; } Hehehe Thanks for the amazing css content!
@jonasjo9091
@jonasjo9091 3 жыл бұрын
hey CSS master , Please do video about fluid images (responsive images)
@Septenien
@Septenien 2 жыл бұрын
For the old sticky footer solution with a fixed height, I very often see a solution with height: auto; min-height: 100%; for the wrapper. Do you know why there is this additional height: auto? I think min-height should be enough, especially because auto is the default, right? Is it for old browsers? Maybe you have a link for me or some reason, can't figure this out :(
@maddancing
@maddancing 3 жыл бұрын
Just asking for clarification, 3:50 it's stuck at 500px right?
@SauloQuirino
@SauloQuirino 3 жыл бұрын
Excellent vídeo
@Pareshbpatel
@Pareshbpatel Жыл бұрын
Thanks for sharing your CSS knowledge, Kenin {2023-01-10}
@SurajKumar-tn7ne
@SurajKumar-tn7ne 2 жыл бұрын
height: auto is cool but min-height: 100vh is awesome
@gerhardsteenkamp562
@gerhardsteenkamp562 3 жыл бұрын
Is height:auto the same as height:fit-content ??
@sandeepbhambre
@sandeepbhambre 3 жыл бұрын
at 1:09, how the pink background color of the body overflow to fill the viewport??? please explain.
@KevinPowell
@KevinPowell 3 жыл бұрын
It's just the way background works on body, as I said, a bit of a quirk. I should have also shown how it works with images and gradients, because it gets a bit more strange in those situations
@minecrafthowtodude
@minecrafthowtodude 3 жыл бұрын
But what about images
@Haibrayn42
@Haibrayn42 3 жыл бұрын
You want to set a height when you want to have a scroll when overflowing instead of the content growing indefinitely, like the youtube playlist here ->
@nick_jacob
@nick_jacob 3 жыл бұрын
I already knew this. I'm not sure why I'm here. Procrastination maybe?
@petropzqi
@petropzqi 3 жыл бұрын
Yeeeeeeeees!!!
@Chrosam
@Chrosam 3 жыл бұрын
IE11... My arch nemesis
@VITORB82
@VITORB82 3 жыл бұрын
Even John Snow would know something CSS with you. 😂
@kevinniemeyer5938
@kevinniemeyer5938 3 жыл бұрын
It seems to me that you would always want to set your body height to 100% to prevent any problems with any other element using a height of 100%. Am I wrong in assuming that?
You can do that with margins?
14:40
Kevin Powell
Рет қаралды 188 М.
Collapsing margins - what they are and how to deal with them
14:31
Kevin Powell
Рет қаралды 65 М.
I thought one thing and the truth is something else 😂
00:34
عائلة ابو رعد Abo Raad family
Рет қаралды 8 МЛН
Из какого города смотришь? 😃
00:34
МЯТНАЯ ФАНТА
Рет қаралды 2,6 МЛН
Are You Making These CSS Height Mistakes?
8:54
Web Dev Simplified
Рет қаралды 136 М.
Programming Is Cooked
9:30
ThePrimeTime
Рет қаралды 260 М.
min-content, max-content, fit-content - intrinsic sizing with CSS
8:52
CSS em and rem explained #CSS #responsive
16:54
Kevin Powell
Рет қаралды 390 М.
The problems with viewport units
13:23
Kevin Powell
Рет қаралды 366 М.
Can I Beat The King Of CSS Again? - CSS Battle
12:40
Web Dev Simplified
Рет қаралды 249 М.
Use these instead of vh
6:06
Kevin Powell
Рет қаралды 520 М.
How to take control of Flexbox
16:01
Kevin Powell
Рет қаралды 142 М.
The HTML Tags They NEVER Taught You
7:39
Giodev
Рет қаралды 152 М.
I built the same app 10 times // Which JS Framework is best?
21:58
Fireship
Рет қаралды 2,6 МЛН
I thought one thing and the truth is something else 😂
00:34
عائلة ابو رعد Abo Raad family
Рет қаралды 8 МЛН