Fireship · @fireship

10 CSS Pro Tips - Code this, NOT that!

Uploaded April 9, 2021 · Length 9:39

10 CSS Pro Tips - Code this, NOT that!

Summary

Learn 10 CSS pro tips for clean coding, avoiding vendor prefixes, and mastering layout with modern features like flexbox and grid.

  • css
  • css pro tips
  • flexbox
  • grid
  • responsive design
  • css layout
  • css coding

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    in my recent poll with over 75 000

  2. 0:02

    responses css topped the list as the

  3. 0:04

    most painful technology web developers

  4. 0:06

    have to work with they say it's broken

  5. 0:07

    chaotic and too damn hard there's even a

  6. 0:09

    conspiracy that it's bad by design to

  7. 0:12

    protect the app stores but i think css

  8. 0:14

    is awesome

  9. 0:14

    it's definitely bloated and difficult to

  10. 0:16

    learn comprehensively but that's only

  11. 0:18

    because it's had to evolve over the last

  12. 0:19

    25 years

  13. 0:20

    it came out at a time when netscape was

  14. 0:22

    the top browser and the idea of a

  15. 0:24

    responsive layout was more than a decade

  16. 0:25

    away

  17. 0:26

    as more browsers hit the market they all

  18. 0:28

    implemented css in different ways

  19. 0:29

    leading to code that works in one

  20. 0:31

    browser but not the other requiring you

  21. 0:33

    the developer to write a bunch of

  22. 0:34

    confusing vendor prefixes in your code

  23. 0:36

    just to make it work across all browsers

  24. 0:38

    so i totally get why you would hate css

  25. 0:40

    but today is a therapy session where

  26. 0:42

    you'll learn how to write clean css

  27. 0:43

    using modern features

  28. 0:45

    while avoiding the bad code that you

  29. 0:46

    shouldn't have to write in 2021

  30. 0:48

    if you're new here like and subscribe

  31. 0:49

    and leave your favorite css pro tip in

  32. 0:51

    the comments

  33. 0:52

    i'll pick a few of them to win this

  34. 0:53

    one-of-a-kind t-shirt next week the

  35. 0:55

    first thing you need to know

  36. 0:56

    is how to learn css the way not to learn

  37. 0:58

    css is to use a framework like bootstrap

  38. 1:01

    or

  39. 1:01

    tailwind they're sexy tools that can

  40. 1:03

    help you get a nice looking ui quickly

  41. 1:04

    but if you use something like tailwind

  42. 1:06

    in your project

  43. 1:06

    it's like getting married for one you

  44. 1:08

    won't learn css fundamentals you'll

  45. 1:10

    learn tailwind

  46. 1:11

    and two if you ever change your mind

  47. 1:12

    you'll have to go through a very nasty

  48. 1:14

    divorce you want a divorce

  49. 1:16

    i have wings tally i want to fly

  50. 1:19

    when you learn basic css you'll have

  51. 1:20

    more control over your code

  52. 1:22

    creativity and freedom the best piece of

  53. 1:24

    advice that i didn't receive until well

  54. 1:25

    into my web development career was to

  55. 1:27

    learn the css

  56. 1:28

    box model because when you understand it

  57. 1:30

    everything else in the language starts

  58. 1:32

    to make more sense

  59. 1:33

    in fact it's so easy i'll just teach you

  60. 1:35

    the box model right now

  61. 1:36

    think of every html element as a box

  62. 1:38

    inside that box you have the content

  63. 1:40

    which can have a width and height you

  64. 1:41

    can add padding around that box to

  65. 1:43

    squeeze the content then you can add a

  66. 1:45

    border around the outside

  67. 1:46

    then additional invisible space around

  68. 1:48

    the border called a margin

  69. 1:49

    everything in css related to layout and

  70. 1:51

    position is influenced by the box model

  71. 1:53

    if you open up chrome dev tools you can

  72. 1:55

    see how the box model is computed for

  73. 1:57

    any element on the page

  74. 1:58

    and that brings me to tip number two