Which CSS unit is relative to the root element's font size?

  • em
  • px
  • rem
  • vw
The rem unit in CSS is relative to the root element's font size, which makes it a practical choice for creating responsive layouts. Unlike em, which is relative to the font size of its nearest parent, rem is always relative to the font size of the root (html) element.

How do you define the number of columns in a grid layout?

  • By setting the grid-template-rows property
  • By specifying the grid-column-count property
  • By using the grid-areas property
  • By using the grid-columns property
You define the number of columns in a grid layout by specifying the grid-column-count property. This property allows you to set the exact number of columns you want in your grid, providing fine control over your layout.

Suppose you want to target every third list item in a list. Which CSS pseudo-class will you use?

  • :every-third
  • :nth-child(3n)
  • :nth-item(3n)
  • :third-child
To target every third list item in a list, you should use the :nth-child(3n) pseudo-class. This selects elements that are at positions that are multiples of 3 within their parent.

How can you ensure that text remains visible during webfont load?

  • Reduce the font file size
  • Set "font-display: swap;" in your CSS
  • Use "font-style: italic;" for fallback fonts
  • Use JavaScript to handle font loading
To ensure that text remains visible during web font loading, you can set the "font-display" property in your CSS to "swap." This tells the browser to use a fallback font until the web font is fully loaded and ready to display, preventing a "FOUT" (Flash of Unstyled Text) for web fonts.

What value of the display property makes an element behave like a block-level element but allows it to sit inline with other content?

  • block
  • inline
  • inline-block
  • none
The value of the display property that makes an element behave like a block-level element but allows it to sit inline with other content is inline-block. This is particularly useful when you want an element to have block-level properties (like the ability to set width and height) while still flowing inline with adjacent content.

You're developing a website where certain styles should only be applied to screens wider than 768px. How would you set this condition using media queries?

  • @media (min-width: 768px) { /* Styles go here */ }
  • @media (screen, min-width: 768px) { /* Styles go here */ }
  • @media screen (min-width: 768px) { /* Styles go here */ }
  • @media screen and (min-width: 768px) { /* Styles go here */ }
To create a media query for screens wider than 768px, you should use the @media rule, followed by the screen keyword (optional) and and (min-width: 768px). The correct option is @media screen and (min-width: 768px) { /* Styles go here */ }.

Which tool can be used to automatically add vendor prefixes to CSS properties?

  • Babel
  • ESLint
  • PostCSS
  • Webpack
PostCSS is a popular tool used in web development to automatically add vendor prefixes to CSS properties. It is highly configurable and can be integrated into your build process. PostCSS, along with plugins like Autoprefixer, streamlines the process of making your CSS code cross-browser compatible by adding the necessary prefixes.

In a responsive design, you have a sidebar that should stick to the top after scrolling past its initial position but stop sticking when it reaches the footer. Which positioning property would you apply to the sidebar?

  • Absolute
  • Fixed
  • Relative
  • Sticky
To create a sidebar that sticks to the top after scrolling past its initial position but stops sticking when it reaches the footer, you should apply the "position: sticky" property. It maintains the element's natural position until a specified scrolling threshold is reached, and then it behaves as if it were fixed.

What does the "forwards" value for the "animation-fill-mode" property do?

  • It makes the animation continue in its final state after completion.
  • It repeats the animation indefinitely.
  • It reverses the animation direction.
  • It sets the animation to be paused.
The "forwards" value for the "animation-fill-mode" property makes the animation continue in its final state after completion. It ensures that the final keyframe of the animation is retained as the end state even after the animation completes.

Animating properties like opacity and transform is considered more performant because they don't trigger ________ in most browsers.

  • redraws
  • relayouts
  • repaints
  • rerenders
When certain properties like opacity and transform are animated, they are considered more performant because they typically don't trigger relayouts or "reflows" in most browsers. Relayouts are costly in terms of performance and can significantly slow down animations.