Fireship · @fireship
10 CSS Pro Tips - Code this, NOT that!
Uploaded April 9, 2021 · Length 9:39
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.
- 0:00
in my recent poll with over 75 000
- 0:02
responses css topped the list as the
- 0:04
most painful technology web developers
- 0:06
have to work with they say it's broken
- 0:07
chaotic and too damn hard there's even a
- 0:09
conspiracy that it's bad by design to
- 0:12
protect the app stores but i think css
- 0:14
is awesome
- 0:14
it's definitely bloated and difficult to
- 0:16
learn comprehensively but that's only
- 0:18
because it's had to evolve over the last
- 0:19
25 years
- 0:20
it came out at a time when netscape was
- 0:22
the top browser and the idea of a
- 0:24
responsive layout was more than a decade
- 0:25
away
- 0:26
as more browsers hit the market they all
- 0:28
implemented css in different ways
- 0:29
leading to code that works in one
- 0:31
browser but not the other requiring you
- 0:33
the developer to write a bunch of
- 0:34
confusing vendor prefixes in your code
- 0:36
just to make it work across all browsers
- 0:38
so i totally get why you would hate css
- 0:40
but today is a therapy session where
- 0:42
you'll learn how to write clean css
- 0:43
using modern features
- 0:45
while avoiding the bad code that you
- 0:46
shouldn't have to write in 2021
- 0:48
if you're new here like and subscribe
- 0:49
and leave your favorite css pro tip in
- 0:51
the comments
- 0:52
i'll pick a few of them to win this
- 0:53
one-of-a-kind t-shirt next week the
- 0:55
first thing you need to know
- 0:56
is how to learn css the way not to learn
- 0:58
css is to use a framework like bootstrap
- 1:01
or
- 1:01
tailwind they're sexy tools that can
- 1:03
help you get a nice looking ui quickly
- 1:04
but if you use something like tailwind
- 1:06
in your project
- 1:06
it's like getting married for one you
- 1:08
won't learn css fundamentals you'll
- 1:10
learn tailwind
- 1:11
and two if you ever change your mind
- 1:12
you'll have to go through a very nasty
- 1:14
divorce you want a divorce
- 1:16
i have wings tally i want to fly
- 1:19
when you learn basic css you'll have
- 1:20
more control over your code
- 1:22
creativity and freedom the best piece of
- 1:24
advice that i didn't receive until well
- 1:25
into my web development career was to
- 1:27
learn the css
- 1:28
box model because when you understand it
- 1:30
everything else in the language starts
- 1:32
to make more sense
- 1:33
in fact it's so easy i'll just teach you
- 1:35
the box model right now
- 1:36
think of every html element as a box
- 1:38
inside that box you have the content
- 1:40
which can have a width and height you
- 1:41
can add padding around that box to
- 1:43
squeeze the content then you can add a
- 1:45
border around the outside
- 1:46
then additional invisible space around
- 1:48
the border called a margin
- 1:49
everything in css related to layout and
- 1:51
position is influenced by the box model
- 1:53
if you open up chrome dev tools you can
- 1:55
see how the box model is computed for
- 1:57
any element on the page
- 1:58
and that brings me to tip number two


