In CSS preprocessors like SASS and LESS, what feature allows you to use the same piece of CSS in multiple places?

  • Functions
  • Mixins
  • Selectors
  • Variables
Mixins in CSS preprocessors like SASS and LESS allow you to reuse the same piece of CSS in multiple places. By defining a mixin, you can encapsulate a set of styles and then include it wherever needed, promoting code modularity and maintainability. Variables, functions, and selectors are also important features but serve different purposes.

During a site audit, you notice that unminified CSS is delaying the page's Load Time. Which CSS minification and optimization technique would you recommend to improve performance?

  • Tree shaking
  • CSS gzip compression
  • Optimize CSS delivery using a Content Delivery Network (CDN)
  • Use CSS sprites for background images
Minifying and compressing CSS with gzip reduces file size and speeds up load time. Other options may offer benefits, but CSS gzip compression directly addresses unminified CSS impacting load time.

Which tool can be typically used for cross-browser testing of web applications?

  • Adobe Photoshop
  • BrowserStack
  • CodePen
  • GitLab CI
BrowserStack is a popular tool for cross-browser testing, allowing developers to test their web applications on various browsers and devices to ensure a consistent user experience.

When should a developer consider removing vendor prefixes from their CSS, and what is the risk associated with this action?

  • After extensive testing on all browsers
  • As soon as the feature is supported without prefixes
  • Only when using experimental features
  • When the codebase becomes too large
Developers should remove vendor prefixes when the CSS feature is universally supported without prefixes. The risk lies in premature removal, potentially causing compatibility issues in browsers that still require prefixes for the given feature.

How can the @font-face rule be used in CSS?

  • Create links to external font libraries
  • Define custom fonts for use in a stylesheet
  • Embed fonts directly into HTML files
  • Import fonts from a CDN
The @font-face rule in CSS allows the definition of custom fonts. It is essential for web designers to understand how to use this rule to enhance the visual appeal of a webpage through custom font choices.

What CSS property is used to change the alignment of text?

  • text-align: justify;
  • text-decoration: align;
  • align-content: center;
  • text-align: center;
The correct option is text-align: center;. This property is used to horizontally align text. text-align can take values like left, right, center, etc. The other options are incorrect or do not exist in CSS.

You are designing a website for accessibility and need to ensure that text can be resized without breaking the layout. Which CSS units should you consider using for font sizes to achieve this?

  • em
  • px
  • rem
  • vw
To achieve text resizing without affecting layout, using relative units like rem (root em) is ideal. Unlike em, which is relative to the parent, rem is always relative to the root element. This ensures consistent scaling throughout the page, promoting accessibility.

Which CSS units are considered to be relative units that allow for responsive designs?

  • em, rem
  • in, mm
  • pt, pc
  • px, cm
em and rem are relative units in CSS, enabling responsive design. Unlike absolute units like px, em and rem adapt to the font size of the parent or root element, respectively. This flexibility makes them valuable for creating layouts that adjust to different screen sizes and user preferences.

The ________ property in SVG is crucial for defining how an SVG's dimensions are calculated relative to its container.

  • viewBox
  • preserveAspectRatio
  • width-height-ratio
  • container-sizing
The correct option is preserveAspectRatio. This property in SVG is essential for specifying how the aspect ratio of the SVG content should be preserved when it's scaled within its container, ensuring proper rendering in different viewports and layouts.

What is the primary purpose of using the @media print CSS rule?

  • Apply styles specifically for printing
  • Create animations for web pages
  • Define a media query for mobile devices
  • Set the background color of a webpage
The @media print CSS rule is used to apply styles specifically for printing. This allows developers to customize the appearance of a webpage when it is printed, such as hiding unnecessary elements or adjusting the layout for better printability.