Margin and Padding Deep Dive: The basics

Поділитися
Вставка
  • Опубліковано 7 січ 2025

КОМЕНТАРІ • 128

  • @Anon-te2bz
    @Anon-te2bz 6 років тому +32

    What I've learned so far from this vid:
    So padding is creating space inside of a content, while margin is creating space outside of a content. You can also adjust specific spaces for both padding and margin, such as -left, -right, -top, -bottom, or you can all do it in one property. Lastly, using auto will take the biggest space as much as possible. You can also use auto to center objects. However, auto will be calculated as 0 when using it for -top and -bottom.
    Good video, thank you!

    • @KevinPowell
      @KevinPowell  6 років тому +10

      You summed it up the entire video in a couple of sentences. I think I could have made this shorter, lol.

    • @hackzgamezyt
      @hackzgamezyt 4 роки тому

      Someone's taking notes!

  • @closetgrasshopper2627
    @closetgrasshopper2627 6 років тому +34

    Your explanation is so clear and concise. I feel like 90% of programming tuts videos here are some Indian guy or some computer science nerd who have no social skills, trying to explain things but end up just rambling. Thank you for this. VERY MUCH

    • @KevinPowell
      @KevinPowell  6 років тому +5

      You're very welcome Closet Grasshopper! Really glad that you like the video and how I present my stuff :)

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

      @shashanka Mg pretty sure she was referring to the “computer science nerd” as the one with no social skills.

  • @mdchowdhury3874
    @mdchowdhury3874 4 роки тому +10

    Your explanation was very clear. Though I've finished my course, I can say confidently that today, after watching this video, I've learned margin and padding and now, no more nervous about these two confusing things. Thanks, Kevin for your nice video.

  • @pelosuelto70
    @pelosuelto70 5 років тому +18

    You are a Godsend to those learning how to code! I finally understand how margin and padding works in a deeper way. Thank you!! Subbed!

  • @Hannibalism
    @Hannibalism 4 роки тому +2

    Ah, finally someone that gives it loud and clear with no confusing metaphors.

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

      Exactly! Sometimes I prefer watching the indian tutorials because they get straight to the point (even though I don't speak Hindi I somehow learn visually)

  • @tbgan6675
    @tbgan6675 7 років тому +3

    Thumbs up for every series. Helping many of us especially those who just beginner

    • @KevinPowell
      @KevinPowell  7 років тому

      Thanks a lot, and I'm happy to help 😁

  • @NeroIvanY
    @NeroIvanY 7 років тому +4

    Thanks for your work, Kevin. Very clear explanation. Looking forward to the third video! very interested in your thoughts about real life cases!

    • @KevinPowell
      @KevinPowell  7 років тому

      Thanks Ivan, glad you liked it. And that video will be out Friday, so not too long to wait 👍

  • @sebastiandelima7385
    @sebastiandelima7385 4 роки тому +2

    Thank you so much for taking the time to explain these concepts, you can tell that you put a lot of good intention and consideration on this video, it's a total like for me.

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

    Excellent tutorial, there are so many tutos here but this one goes deeper and I finally got it after many years of confusion

  • @abdulrehman5159
    @abdulrehman5159 2 роки тому +1

    Now I understood completely!
    Thanks for the detailed video on the topic.

  • @drummerdev5522
    @drummerdev5522 7 років тому +1

    Great series on margins and padding. One thing that may help new learners with the margin auto centering method is making sure they know the containing div's width. I can't count how many times I tried to use the margin auto method and wanted to shake my computer, because I nested or the parent width was not 100% of the screen size.
    I also enjoyed seeing the BEM naming convention in the third video. It seems to be the current favorite of the industry and it is something I myself am currently trying to get into the habit of using. :)

    • @KevinPowell
      @KevinPowell  7 років тому

      Oh man, I totally should have mentioned giving it a width for that to work, totally missed the mark on that. Thanks for mentioning it though, I'll add it in the description of the video.
      I always liked the concept of BEM, but the whole double underscore thing sort of annoyed me, but the more complicated projects you work on, you start to see the benefit of it all. I'm happy I'm playing around with it now, and I think it's won me over at this point.

  • @NeoKarthik
    @NeoKarthik 5 років тому +3

    I finally get he margin: auto statement. Thank you so much!

  • @adhityapoernama940
    @adhityapoernama940 6 років тому +3

    A very straight and clear explanation video! thank you!

    • @KevinPowell
      @KevinPowell  6 років тому

      Thanks, glad that you liked it!

  • @hellobenjir
    @hellobenjir 7 років тому

    I just loved this series and the way you explained it easily.Looking forward to watch next :)

    • @KevinPowell
      @KevinPowell  7 років тому

      Thanks Benjir, glad you liked it :)

  • @brogen100
    @brogen100 5 років тому

    mind blown!
    I nominate you teacher of the year

  • @BUDX
    @BUDX 4 роки тому

    Thank you very much for explaining this.
    I was really struggling with this but now it's all clear.

  • @robertrydlewski9538
    @robertrydlewski9538 6 років тому +1

    Kevin ... Your the best, period. Thanks a lot

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

    Thanks Kevin for clarifying this 👏🏽

  • @maran.ath4
    @maran.ath4 2 роки тому

    he literally took oversimplification to another level, I wish all my teachers were like you🥲thanks a bunchhh

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

    Beautifully Explained. Thank You.

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

    I am a full stack developer bodge together website and i have no fing clue what im doing with css but your videos help me a lot thank you

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

    Yeah I got this. Choose according to your need. If you are done with margin, stick with it. If padding can do it, use padding.

  • @paketa7736
    @paketa7736 4 роки тому

    You are a great teacher. Thank you, teacher!

  • @arvindk4813
    @arvindk4813 4 роки тому +1

    I was looking for this , yeah this is it thank you.

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

    Feel lucky to know you from the very beginning I learn CSS

  • @JonFuller1004
    @JonFuller1004 7 років тому +1

    One thing I have bumped into recently was padding and or margin was causing my elements to break out of the container when using grid. Not quite sure why they wanted to do that. I thought with grid. If the size of he object or the margin or padding got to wide it would auto go on to next column.
    Maybe I was mucking something up

    • @KevinPowell
      @KevinPowell  7 років тому +1

      Nah, things will overflow outside of their cell if they are bigger than the cell. By default, something will be taking up one row and one column, it won't automatically assume that it should actually take up two. That *could* be a cool behaviour, but I could also see it causing some problems.

  • @Brospeh00
    @Brospeh00 4 роки тому

    Very informative, thanks Kevin!

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

    Thank you. Do you recommend using background or background-color when setting a colored background?

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

    first time to know the difference... thanks

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

    Thank you for the clear explanation.

  • @RamonMartinez-jz9uv
    @RamonMartinez-jz9uv 6 років тому +2

    Great job Kevin, very clear video. A couple questions seem to arise though...does it seem strange that css defaults div boxes to the upper left hand corner? Like why wouldn't it default to any other alignment, say centered, or to the upper right corner, or lower left corner? Is that just per the spec--and if so where can we view the spec details themselves? My initial guess was CSS mimics the left to right nature of western languages, but then why does CSS stack the boxes in a column and not in a row, again as western languages do? Any thoughts are greatly appreciated.

    • @KevinPowell
      @KevinPowell  6 років тому +2

      Divs are block-level elements. Any block level element automatically starts a new line of content and takes up the full width of its parent (by default). This is also why it stacks things, because block-level elements automatically start a new line of content, whereas inline and inline-block elements do not. A div behaves the same way as a paragraph, they are both block-level. If paragraphs created columns instead of new rows of content, that would be a pain!
      If we give it a set width, then yes, it's on the left side. It starts at the top because, well, I'm not 100% sure where in the specifications it talks about that, but if it didn't it would be hard to build a website (from bottom to top???). I could be wrong, but starting from the top makes it a lot easier than anything else, that way our content follows the flow of the HTML we're writing.
      As far as it being on the left, if we give it a width, yes, it's on the top left. However, like you said, if you set your site up for a right-to-left language, it would go to the top right, instead of top left (you can read more on that here: www.w3.org/International/questions/qa-html-dir ). This, I think, makes a lot of sense.
      As far as the documentation, w3.org is where all of it would be, in relation to the standards, though I often find that the MDN is much more user-friendly as it includes examples and browser support tables, as also links to both the existing standard, as well as working drafts for future implimentations - developer.mozilla.org/en-US/

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

    Please correct me if i am wrong
    Margin creates space outside the element with the content on the inside and padding creates space on the inside?

  • @rahuldora1587
    @rahuldora1587 4 роки тому

    Awesome explanation love It ❤️

  • @marcusmorrow3900
    @marcusmorrow3900 5 років тому

    Good stuff. Well explained

  • @calvinebun-amu5397
    @calvinebun-amu5397 4 роки тому

    Great video, Kevin.

  • @moritz584
    @moritz584 4 роки тому +1

    great vid!

  • @space_monkey125
    @space_monkey125 7 років тому +1

    Hi kevin, thanks for the awesome videos. It helps me alot. :)

  • @ingridhernandez2782
    @ingridhernandez2782 4 роки тому

    I appreciate your videos so much. Thank you

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

    Hi , can you help me with a website i build I have a problem with show more bottom and the position of the bottom. If u will I'll show you the code and pic for the problems please help me

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

    KING OF CSS!

  • @jashanpreet880
    @jashanpreet880 4 роки тому +1

    welll done sir i was struggling with this property

  • @cow240
    @cow240 4 роки тому

    very useful, thanks! However you mentioned margin-left and margin-right 0 will centre it across the screen at the 12.03 minute mark. Is that right?

  • @anyzzas7149
    @anyzzas7149 6 років тому +1

    Thanks for the good tutorial.

  • @iboro-kun84
    @iboro-kun84 4 роки тому

    No, thank you, Mr Powell. You're awesome, not a little bit.🤝

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

    This is going to seem like a stupid question, (and more than likely is). But, if you set for values for the margin ( say 100 50 100 50 and it sets these in a clockwise fashion, you then erase the last one so it is now 100 50 100, why would css use the 50 value instead of just using the default (since there is no value assigned to it)? Yes i am VERY new to all of this. (HTML, CSS...all of it.)

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

    Great explanation.

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

    So i can use margin to change the position right?

  • @SmokyBigSmoke
    @SmokyBigSmoke 4 роки тому

    loved the explanation..tysm buddy..

  • @mahdi3521
    @mahdi3521 4 роки тому

    man can't thank u enough legend

  • @vampirekabir
    @vampirekabir 6 років тому

    man!you explain like a bosss!!

    • @KevinPowell
      @KevinPowell  6 років тому

      Thanks! Super glad you liked it!

  • @webb-developer
    @webb-developer Рік тому

    perfectly explained ✅

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

    ive been curious about how gap also fits into this

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

    I don't see a link to the codepen.

  • @adarshsoni5323
    @adarshsoni5323 7 років тому +5

    Hi Kevin please make video series on JavaScript from beginners to expert level .....please

    • @KevinPowell
      @KevinPowell  7 років тому +3

      I'll be making and using JavaScript more, but I think a whole series would kill me, haha. There is just sooooo much to cover.

  • @KradianKrad
    @KradianKrad 4 роки тому

    Best explanation!

  • @gaetanoalessandro286
    @gaetanoalessandro286 4 роки тому

    Hi, thanks a lot for sharing your knowledge: you 're helping me!! :-)

  • @everlastproducciones9280
    @everlastproducciones9280 4 роки тому

    Thanks for your time

  • @damion5874
    @damion5874 5 років тому

    Thanks for the teaching. Looks like the thumb nail for this video has a misspelling.

  • @mohammadakramsheik1657
    @mohammadakramsheik1657 5 років тому

    Best video, thank u very much

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

    Thank you Kevin.

  • @alvarocarrilho
    @alvarocarrilho 5 років тому

    Thks From Lisbon - Portugal

  • @learntocode1878
    @learntocode1878 5 років тому

    Hi Kevin, thank you for this video brother. I subscribed. Your videos are the best. Can you please show how to create a one page scroll

  • @AmanSharma-bv4ii
    @AmanSharma-bv4ii 2 роки тому

    thank you uncle 🙏🏼

  • @BishalDas-xu4zi
    @BishalDas-xu4zi 3 роки тому

    A thanks from an Indian ❤️

  • @tanushs08
    @tanushs08 4 роки тому

    10:50 margin top : auto = 0
    margin bottom : auto = 0

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

    The thumbnail says Bascis. Is it intentional or no one noticed in 3 years ?

  • @wholeness
    @wholeness 5 років тому +15

    Just for the observer, you never actually answered the question when to use one versus the other. Great tutorial though.

    • @KevinPowell
      @KevinPowell  5 років тому +14

      It's not always so simple, but I like to look at it as padding for more background, margin for extra space.

  • @khilapsingh2838
    @khilapsingh2838 7 років тому

    Thank you very much Kevin!!!!!!

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

    Thanks for that Sir.

  • @baljeetgulati4605
    @baljeetgulati4605 4 роки тому

    hats off to u sir!

  • @bloc-notes6751
    @bloc-notes6751 5 років тому

    You are the best !

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

    my mam used to say, "never trust a man who does a spelling mistake in a thumbnail"

  • @happyhuman8549
    @happyhuman8549 6 років тому

    pls make a video about borders!!

    • @KevinPowell
      @KevinPowell  6 років тому

      What do you want to know about borders? I generally don't do much with them, so I'm curious :)

  • @SM-ok3sz
    @SM-ok3sz 3 роки тому

    Your title card is misspelled

  • @shrookwageh5976
    @shrookwageh5976 5 років тому

    what to say. you're so awesome

  • @MesutAkcan
    @MesutAkcan 5 років тому +1

    the very BASCiS !!! ???

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

    Margin does not affect element width, its just border and padding, no?

  • @js_programmer8423
    @js_programmer8423 5 років тому

    so padding is basically height & width in an alternative way

    • @KevinPowell
      @KevinPowell  5 років тому

      A more dynamic way, yes :) - will adjust to your content, which is nice.

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

    Thank you!

  • @tristanmckellen9972
    @tristanmckellen9972 4 роки тому

    thank you so much!

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

    thought this was about stocks.. i was eating then was sooooo confused when he started coding lmao oops wrong video

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

    Your thumnail for this video has a Typo

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

    your video's, maks me feel, that I have progess

  • @wilfredomendez3450
    @wilfredomendez3450 7 років тому

    Sweet, thanks

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

    very helpful. but the image is "the very bascis" :)

  • @seemsas
    @seemsas 7 років тому

    Thank you

  • @dhanushsivajaya1356
    @dhanushsivajaya1356 4 роки тому

    Thankyou sir

  • @dynamic-homepages
    @dynamic-homepages 3 роки тому

    Thanks =)

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

    damn, i wanmted you to explain border

  • @TheCrusaderRabbits
    @TheCrusaderRabbits 6 років тому

    It is good.

    • @KevinPowell
      @KevinPowell  6 років тому

      Thanks, glad you liked it :D

  • @elhamzeinodini4828
    @elhamzeinodini4828 4 роки тому

    💥🌹

  • @psyrotix2463
    @psyrotix2463 6 років тому +6

    "Deep Dive: The Basics" LOL

    • @KevinPowell
      @KevinPowell  6 років тому +3

      Gotta start somewhere with the deep dive 😁

    • @psyrotix2463
      @psyrotix2463 6 років тому

      No I was just laughing at the oxymoron, great video though!

  • @ycombinator765
    @ycombinator765 4 роки тому

    B A S C I S

  • @willl0014
    @willl0014 6 років тому

    Black deep!!

  • @pratikbhandari6679
    @pratikbhandari6679 4 роки тому +1

    On the thumbnail
    I think its "basics" not "bascis"
    🤣🤣🤣

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

    it works very, exactly, much the same... hahahah, oookay.

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

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

    .

  • @nikhilb3880
    @nikhilb3880 4 роки тому

    come on, why do you need to have a 2 min introduction of basically nothing about the topic

  • @karolinalencina7121
    @karolinalencina7121 4 роки тому

    thank you so much!!!