Home Icon

Week 2 Exercises - CSS

  1. What are the main differences between external, internal, and inline CSS?
  2. The main diference is related to specificity of the rules (inline is the most specific but less practical) and loading time (external CSS will need to download the file first and then render the styles).

  3. What is the syntax for class and ID selectors?
  4. .class and #id

  5. How would you apply a single rule to two different selectors?
  6. .selectorOne, .selectorTwo {

  7. Given an element that has an id of title and a class of primary, how would you use both attributes for a single rule?
  8. #title.primary {

  9. What does the descendant combinator do?
  10. The descendant combinator allows the developer to change the style of a child element if is present in the parent element.

  11. Between a rule that uses one class selector and a rule that uses three type selectors, which rule has the higher specificity?
  12. The class selector rule because is more specific

  13. From inside to outside, what is the order of box-model properties?
  14. Content > padding > border > margin

  15. What does the box-sizing CSS property do?
  16. Changes the box-sizing property to the specified property (padding-box or border-box)

  17. What is the difference between the standard and alternative box model?
  18. When setting the width/height of the element, the standard box model only takes in consideration the content box, while the alternative box model takes in consideration the content box + padding + border

  19. Would you use margin or padding to create more space between 2 elements?
  20. Margin

  21. Would you use margin or padding if you wanted two elements to overlap each other?
  22. Margin

  23. What is the difference between a block element and an inline element?
  24. The inline element only takes the necessary width and doesn’t start in a new line. A block element always starts in a new line and as a margin before and after.

  25. What is the difference between an inline element and an inline-block element?
  26. An inline element does not respect the width/height properties, but the inline-block does

  27. Is an h1 block or inline?
  28. Block

  29. Is button block or inline?
  30. Block

  31. Is div block or inline?
  32. Block

  33. Is span block or inline?
  34. Inline

  35. Whats the difference between a flex container and a flex item?
  36. The flex container is the container where the flex properties are set and the flex item are the child elements inside the flex container

  37. How do you create a flex item?
  38. Set display: flex to the parent container of the flex item

  39. What are the 3 values defined in the shorthand flex property?
  40. Flex grow, shrink and basis

  41. How do you make flex items arrange themselves vertically instead of horizontally?
  42. Display: column

  43. What is the difference between justify-content and align-items?
  44. Justify-content defines the alignment along the main axis, while the align-items align the items on the cross axis

  45. How do you use flexbox to completely center a div inside a flex container?
  46. FlexContainer {Display: flex; Flex-direction: column; justify-content: center; align-items: center;

  47. Whats the difference between justify-content: space-between and justify-content: space-around?
  48. Space-between will distribute the space between the flex items without any space at the ends, while the space around will distribute the space evenly including the flexs items on the ends of the parent element

Header 1

Header 2

Header 3

Header 4