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.
If you want to vertically center an inline or inline-block element relative to its parent, you'd set "vertical-align" to ________.
- baseline
- center
- middle
- top
To vertically center an inline or inline-block element relative to its parent, you'd set the "vertical-align" property to middle. This property allows you to control the vertical alignment of inline-level elements within their line boxes.
What is SASS primarily used for in web development?
- Styling web pages with JavaScript
- Compiling code into machine language
- Enhancing website security
- Simplifying and organizing CSS
SASS (Syntactically Awesome Style Sheets) is primarily used in web development for simplifying and organizing CSS. It introduces features like variables, nesting, and mixins, making your CSS more maintainable and efficient.
The CSS function clamp() restricts a value between a specified ______ and ______.
- left, right
- lower, upper
- minimum, maximum
- start, end
The CSS clamp() function is used to restrict a value between a specified minimum and maximum value. It allows for responsive design by ensuring that the value falls within this range, helping to maintain a consistent layout across different screen sizes.
You're optimizing a website for better scroll performance. Which CSS property would you use to hint to the browser about an element that will change frequently?
- position: fixed;
- transform: translate3d(0,0,0);
- will-change
- z-index
To optimize scroll performance, you can use the will-change property to hint to the browser that an element will change frequently. This allows the browser to prepare for the changes and allocate resources accordingly, improving scrolling performance. While using transform: translate3d(0,0,0); can also trigger hardware acceleration, it may not be as specific or efficient as will-change. z-index and position: fixed; are unrelated to hinting to the browser about frequent changes in an element.
The BEM methodology suggests a naming convention where the block is separated from the element by a ________.
- -
- .
- :
- _
BEM (Block Element Modifier) methodology recommends using an underscore (_) to separate the block from the element in class names. This naming convention enhances code readability and helps identify the hierarchy of elements within a block. For instance, a button element inside a header block might be named header_button.