What's the deal with height: auto?

Поділитися
Вставка
  • Опубліковано 15 вер 2024

КОМЕНТАРІ • 155

  • @CodingNuggets
    @CodingNuggets 3 роки тому +144

    Love when you cover anything CSS. I feel like I level up a little with each video. Thanks Kevin!

    • @kaanergunlu7836
      @kaanergunlu7836 2 роки тому

      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.

  • @TKYasser
    @TKYasser 3 роки тому +32

    Daamn, I'm sure you are better with CSS than the CSS creator himself xD

  • @adithyas6863
    @adithyas6863 3 роки тому +6

    Ever since I've subscribed, it seems I am getting more and more better at CSS, please keep this up! RESPECT 100

  • @modelshipwrights
    @modelshipwrights 3 роки тому +5

    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 роки тому +12

    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?

  • @elahhaz1047
    @elahhaz1047 3 роки тому +2

    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!

  • @louisgamor
    @louisgamor 3 роки тому +5

    Kevin is undeniably the BEST. He's like the Boyka in the CSS Ring 😍

  • @mohan9285
    @mohan9285 3 роки тому +1

    You simplify the complex topics and makes very easy to understand :)

  • @Minu_Shalom
    @Minu_Shalom 3 роки тому +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 :)

  • @OmniscientIgnorance
    @OmniscientIgnorance 3 роки тому +1

    You really are the CSS king! Love your videos so much.

  • @otmanm4095
    @otmanm4095 3 роки тому +1

    I really love these kind of videos. Really thanks for all the content.

  • @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!

  • @VasilyPavlik
    @VasilyPavlik 3 роки тому +1

    Excellent. Very useful for beginners and not only for them.
    Kevin, your hair has "height: auto" after quarantine :)

    • @KevinPowell
      @KevinPowell  3 роки тому +1

      haha, totally. I think this is my last video before my haircut, lol.

  • @ragnarlothbrook8117
    @ragnarlothbrook8117 3 роки тому

    Useful stuff. I really dig this kind of short and 'to the point' vids you make.

  • @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.

  • @yousif2712
    @yousif2712 3 роки тому +4

    Great video! Keep the pink background next time please, easier on the eyes haha

  • @somnvm37
    @somnvm37 3 роки тому +2

    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

  • @venkatmani7167
    @venkatmani7167 3 роки тому

    It is really wonderful to see your explanation which will clear lot of questions around min-height and height.

  • @SudeeptoDutta
    @SudeeptoDutta 3 роки тому +2

    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 роки тому +1

      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 роки тому +1

      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.

  • @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.

  • @PatrikKulisek
    @PatrikKulisek 3 роки тому +1

    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.

  • @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.

  • @resty1672
    @resty1672 3 роки тому

    Always get indepth pro tips from your channel,big thank!

  • @itallovidal9383
    @itallovidal9383 3 роки тому +2

    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 :)

  • @matrixdeterminant3629
    @matrixdeterminant3629 3 роки тому

    Thanks Kevin!!! Your videos are extremely helpful!

  • @guillermoandradaFSD
    @guillermoandradaFSD 3 роки тому

    It was easy before this video but you made it easier that time... Txs a lot

  • @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!

  • @sebacamposdev
    @sebacamposdev 3 роки тому

    thanks for the video. And yeah this video needs a part 2 with grid and flexbox

  • @diegoraffa4324
    @diegoraffa4324 3 роки тому

    Hi Kevin!
    You are awesome!
    Looking forward your live on Scrimba and your Sass course in future.😁

  • @WojciechKobus
    @WojciechKobus 3 роки тому

    You're doing a good job. Thanx for input.

  • @ali-celebi
    @ali-celebi 3 роки тому

    Great explanation! Quality content as usual :)

  • @Aabara_ka_dabara
    @Aabara_ka_dabara Рік тому

    thankyou for this video. it really helped me to understand this

  • @lestherxm
    @lestherxm 10 місяців тому +1

    Finally, I'm able to don't overflow the text on my containers, lol

  • @1998Hagis
    @1998Hagis 3 роки тому

    You could show the mix of min-height: 100px; and max-height:100%;
    That is a great connections!

  • @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

  • @TristanGrimaux
    @TristanGrimaux 3 роки тому +1

    "And we can see that we have that red border there, that's my body". Best line ever

  • @DrHappybone
    @DrHappybone 3 роки тому

    That was really well explained, dude!

  • @jayjohn3634
    @jayjohn3634 3 роки тому

    Hey man, I am loving the videos!

  • @SnSungod7
    @SnSungod7 3 роки тому

    Thank you that really helped me clear lot of my doubts

  • @procrastinator24
    @procrastinator24 2 роки тому

    great video, thank you so much!

  • @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.

  • @venkatanagasai1579
    @venkatanagasai1579 3 роки тому

    Sure this video gonna help me. Thanks sir..

  • @linh92nguyen53
    @linh92nguyen53 3 роки тому

    so touching for an excellent video

  • @johanjong7208
    @johanjong7208 3 роки тому +1

    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.

  • @80Vikram
    @80Vikram 2 роки тому

    Cool hairstyle Kevin, who is your barber ?

  • @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.

  • @theartofwarren
    @theartofwarren 3 роки тому

    Nice bite-size tidbit-thanks!

  • @TytusDubel
    @TytusDubel 3 роки тому

    thank You Kevin

  • @jamaluddin9158
    @jamaluddin9158 3 роки тому +1

    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 😅

  • @SUKI12809
    @SUKI12809 3 роки тому

    Thanks you, new knowledge about CSS.

  • @justnevergiveup6761
    @justnevergiveup6761 2 роки тому

    You're the best, Thanks.

  • @shahbazkhalid6950
    @shahbazkhalid6950 2 роки тому

    Kindly makes videos on these topics Vanilla JS , Bootstrap 5, Gradients & functions in CSS3 and when to use gradients and function,

  • @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....

  • @mushfiqursorol6667
    @mushfiqursorol6667 3 роки тому

    Sir Your Very Good Explainer
    When You Covered Something
    Hurd Things Be Come Esay And Simple Thank You Sir

  • @hnccox
    @hnccox 3 роки тому

    From now on, I am going to set the body always to a min-height of 100vh

  • @theshredguitarist25
    @theshredguitarist25 3 роки тому

    1:54 so helpful!

  • @arthurdoomer
    @arthurdoomer 3 роки тому +1

    .yourHair {
    auto;
    }
    Hehehe
    Thanks for the amazing css content!

  • @lambo-ca
    @lambo-ca 3 роки тому

    Thanks man.

  • @twanasoftwareengineer1754
    @twanasoftwareengineer1754 3 роки тому +1

    " Percentage of height is always percentage of the parent " ❤

  • @fah199990
    @fah199990 3 роки тому

    I love css !! And i like you video

  • @mohitpandit3041
    @mohitpandit3041 2 роки тому

    Thanks for explain it.. But no need to set height : auto. By default every elements have height auto

  • @baltazarreis5590
    @baltazarreis5590 Рік тому

    Very nice!

  • @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.

  • @vasilemidrigan50
    @vasilemidrigan50 3 роки тому

    Thanks a lot!!!

  • @venkatesh2788
    @venkatesh2788 3 роки тому

    Please make SEO full course with projects

  • @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?

  • @kunited9
    @kunited9 3 роки тому

    Great explanation

  • @RubberDuckCoding
    @RubberDuckCoding 2 роки тому

    VERY NICE!

  • @pavankumarvangala2548
    @pavankumarvangala2548 3 роки тому

    Hi Kevin , Can you please make a video on Display options like flex, grid , inline-flex etc.. Thanks in advance

  • @SauloQuirino
    @SauloQuirino 3 роки тому

    Excellent vídeo

  • @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?

  • @quickcodingtuts
    @quickcodingtuts 3 роки тому

    Also you can't do transitions from a certain height to auto, which kinda sucks :/

    • @KevinPowell
      @KevinPowell  3 роки тому +1

      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.

  • @truedivan
    @truedivan 3 роки тому

    Thank you!)

  • @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.

  • @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 :(

  • @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;
      }

  • @jonasjo9091
    @jonasjo9091 3 роки тому

    hey CSS master , Please do video about fluid images (responsive images)

  • @vivekv4250
    @vivekv4250 3 роки тому

    Love your videos.. love from India

  • @samithraniroshana4089
    @samithraniroshana4089 3 роки тому

    Very very very useful ❤

  • @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.

  • @kallekula9202
    @kallekula9202 3 роки тому

    Then what's the different between heigh auto and height fit-content?

  • @PC-tk7uv
    @PC-tk7uv 3 роки тому

    whats the diffence between height auto and not setting the height at all

  • @sandeepbhambre
    @sandeepbhambre 3 роки тому

    at 1:09, how the pink background color of the body overflow to fill the viewport??? please explain.

    • @KevinPowell
      @KevinPowell  3 роки тому +1

      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

  • @maddancing
    @maddancing 3 роки тому

    Just asking for clarification, 3:50 it's stuck at 500px right?

  • @awekeningbro1207
    @awekeningbro1207 3 роки тому +1

    isn't 'auto' the default value of height?

  • @brianjett1446
    @brianjett1446 2 роки тому

    What is the difference between max-hight and min-hight?

  • @pearlboy
    @pearlboy 3 роки тому

    Awesome

  • @Pareshbpatel
    @Pareshbpatel Рік тому

    Thanks for sharing your CSS knowledge, Kenin
    {2023-01-10}

  • @Chrosam
    @Chrosam 3 роки тому

    IE11... My arch nemesis

  • @mdtajbirhossain8228
    @mdtajbirhossain8228 3 роки тому

    Is there any different between auto and fit-content?

  • @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?

  • @misterhtmlcss
    @misterhtmlcss 2 роки тому

    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.

  • @Sothatjusticecanbedo
    @Sothatjusticecanbedo 2 роки тому

    Thanks

  • @VITORB82
    @VITORB82 3 роки тому

    Even John Snow would know something CSS with you. 😂

  • @KarimShalapy
    @KarimShalapy 3 роки тому

    Heights have the same rules for ?

  • @bradyfractal6653
    @bradyfractal6653 3 роки тому

    Ok but what’s the difference between AUTO and MAX-CONTENT, because as you describe, they are identical.

  • @shreysharma9653
    @shreysharma9653 3 роки тому

    I am not sure why? ...but my 100% height attribute give 100% viewport height. No idea why?

  • @nick_jacob
    @nick_jacob 3 роки тому

    I already knew this. I'm not sure why I'm here. Procrastination maybe?

  • @SurajKumar-tn7ne
    @SurajKumar-tn7ne Рік тому

    height: auto is cool
    but
    min-height: 100vh is awesome