Fireship · @fireship

CSS in 100 Seconds

Uploaded December 14, 2021 · Length 2:20

CSS in 100 Seconds

Summary

css basics: selectors, rules, box model, layout, media queries, animations in 100 seconds.

  • css basics
  • css selectors
  • css rules
  • css box model
  • css layout
  • css media queries
  • css animations

Transcript preview

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

  1. 0:00

    cascading stylesheets or css is a

  2. 0:02

    stylesheet language famous for making

  3. 0:04

    websites look pretty by default a

  4. 0:06

    browser will render HTML as a boring

  5. 0:09

    black and white document CSS allows you

  6. 0:11

    to describe the presentation of this

  7. 0:13

    markup by modifying the size color

  8. 0:16

    positioning and layout of HTML elements

  9. 0:19

    it was first released in 1996 and

  10. 0:21

    evolved into CSS 3 by 1999 the language

  11. 0:24

    continues to evolve to this day with new

  12. 0:26

    features but there will never be a CSS 4

  13. 0:29

    just updates to the existing language

  14. 0:31

    the typical CSS rule starts with a

  15. 0:33

    selector that can be matched to an

  16. 0:34

    element in the HTML document you then

  17. 0:37

    use braces to create a declaration block

  18. 0:39

    that contain properties that change the

  19. 0:41

    appearance of that element this is known

  20. 0:43

    as a CSS rule but the tricky thing is

  21. 0:45

    that stylesheets Cascade a stylesheet

  22. 0:48

    might contain multiple rules that apply

  23. 0:50

    to the same element this creates a

  24. 0:51

    hierarchy and rules that are more

  25. 0:53

    specific will overwrite the rules of

  26. 0:55

    their parents in other words the order

  27. 0:57

    of your CSS rules matter in addition

  28. 0:59

    some elements will inherit the styles of

  29. 1:01

    their parent but others will not

  30. 1:03

    ultimately the browser uses the concepts

  31. 1:05

    of cascade specificity and inheritance

  32. 1:08

    to control which styles are applied to

  33. 1:10

    an element to get started open up a

  34. 1:12

    style tag in any HTML document a

  35. 1:14

    selector can Target all HTML elements of

  36. 1:17

    a certain type multiple related elements

  37. 1:19

    with a custom class or a single element

  38. 1:21

    with an ID now think of every HTML

  39. 1:23

    element like a box the content is in the

  40. 1:26

    middle followed by padding border and a

  41. 1:28

    margin the amount of real estate used by

  42. 1:30

    every area in the Box can be customized

  43. 1:33

    by defining properties like padding and

  44. 1:35

    margin they can take explicit pixel

  45. 1:37

    values or responsive values that are

  46. 1:39

    relative to the parent element or a

  47. 1:41

    percentage of the viewport itself now

  48. 1:43

    these boxes will bump into each other to

  49. 1:44

    make up a web page but you can use tools

  50. 1:47

    like Flex layout and grid layout to

  51. 1:49

    control how they float together in a

  52. 1:50

    sophisticated way it can also detect

  53. 1:52

    user interaction with pseudo selectors

  54. 1:55

    like hover CSS also makes it possible to

  55. 1:57

    add logic to your code with variables or

  56. 1:59

    custom properties and by making media