W3Schools CSS Selectors and Layout Quiz

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Thames
T
Thames
Community Contributor
Quizzes Created: 11982 | Total Attempts: 187,298
| Questions: 20 | Updated: Aug 15, 2026
Please wait...
Question 1 / 21
🏆 Rank #-- ▾
0 %
0/100
Score 0/100

1. What is the difference between margin and padding?

Explanation

Padding is the space between an element’s content and its border, so it is inside the box. Margin is the space outside the border, separating the element from neighboring elements.

Submit
Please wait...
About This Quiz
W3Schools CSS Selectors and Layout Quiz - Quiz

This quiz evaluates your mastery of CSS selectors and layout techniques essential for modern web design. Test your understanding of selector specificity, combinators, flexbox, grid, and positioning models. Perfect for college-level learners aiming to build solid CSS foundations and advance their web development skills.

2.

What first name or nickname would you like us to use?

You may optionally provide this to label your report, leaderboard, or certificate.

2. What does the CSS @media rule enable?

Explanation

The `@media` rule applies CSS conditionally based on the output medium or device characteristics, such as screen size or orientation. It can also target specific media types, including print, allowing a page to use different styles when printed.

Submit

3. Which combinators can you use to select child elements in CSS?

Explanation

In CSS, the `>` combinator selects only elements that are direct children of a specified parent. A space combinator selects matching elements at any depth within that parent, including nested descendants. Use `>` for immediate children and a space when you want to target all descendants.

Submit

4. The box-sizing property set to border-box includes which dimensions?

Explanation

With `box-sizing: border-box`, an element’s specified width and height include its content, padding, and border. Margins remain outside those dimensions, so they are not included.

Submit

5. What does the CSS transform property allow?

Explanation

The CSS `transform` property changes an element’s position, size, or orientation using functions such as `translate()`, `scale()`, `rotate()`, and `skew()`. It affects how the element is visually rendered without changing its normal document flow.

Submit

6. Which property makes text wrap within a container?

Explanation

The `word-wrap` property lets long words break onto a new line when they would otherwise overflow their container. This helps keep text within the available space and prevents horizontal overflow. In modern CSS, `word-wrap` is an alias for `overflow-wrap`, but `word-wrap` is the matching choice among the options provided.

Submit

7. In CSS Grid, what does the fr unit represent?

Explanation

In CSS Grid, **fr** represents a flexible fraction of the available space in a grid container. Tracks sized in fractions share that space according to their relative values—for example, a `2fr` track receives twice as much space as a `1fr` track, after fixed sizes and gaps are accounted for.

Submit

8. The :not() pseudo-class is used to select which elements?

Explanation

The `:not()` pseudo-class selects elements that do not match the selector specified inside its parentheses. For example, `p:not(.highlight)` selects paragraph elements that do not have the `highlight` class.

Submit

9. What does the flex-grow property do?

Explanation

The `flex-grow` property determines how flex items expand to use extra space in their container. Items with higher grow values receive a proportionally larger share of the available space.

Submit

10. Which selector matches elements with a specific attribute value?

Explanation

CSS attribute selectors target elements according to their attributes. `[attr]` matches elements that have the attribute, `[attr=value]` matches when its value exactly equals `value`, and `[attr*=value]` matches when the value contains `value` anywhere. Thus, all listed forms qualify as attribute selectors, though they test different attribute conditions.

Submit

11. Which CSS selector has the highest specificity?

Explanation

An ID selector has higher specificity than class and element selectors, so it takes precedence when competing CSS rules apply to the same element. The universal selector has the lowest specificity.

Submit

12. In grid layout, what does grid-auto-flow property determine?

Explanation

The `grid-auto-flow` property controls how the browser places grid items when their positions are not explicitly specified. It determines whether items fill the grid by rows or columns and can optionally allow dense packing to fill gaps. It does not set the grid’s column count, spacing, or item sizes.

Submit

13. Which property controls the stacking order of positioned elements?

Explanation

The `z-index` property controls the stacking order of positioned elements, determining which elements appear in front of or behind others when they overlap. Higher `z-index` values generally place elements closer to the front.

Submit

14. What does the CSS calc() function allow you to do?

Explanation

The `calc()` function lets you perform arithmetic—such as addition, subtraction, multiplication, and division—within CSS property values. It can combine compatible units, for example, `width: calc(100% - 20px)`.

Submit

15. The :nth-child(2n) pseudo-class selector targets which elements?

Explanation

The `:nth-child(2n)` selector matches children in positions 2, 4, 6, and so on. Since these are the even-numbered positions, it selects all even-numbered children.

Submit

16. Which CSS property defines the gap between grid items?

Explanation

The `gap` property sets the space between rows and columns in a CSS grid container. It can define both gaps at once or be adjusted separately with `row-gap` and `column-gap`.

Submit

17. What is the default value of the display property for a div element?

Explanation

A `

` element is a block-level element by default, so its `display` property is `block`. It typically starts on a new line and expands to fill the available width of its parent unless other styles change its layout.
Submit

18. Which value of the position property removes an element from the document flow?

Explanation

Setting `position: absolute` removes an element from the normal document flow, so it no longer takes up space or affects the placement of surrounding elements. It is positioned separately, typically relative to its nearest positioned ancestor. By contrast, `relative`, `static`, and `sticky` elements remain in the document flow.

Submit

19. In flexbox, what does the justify-content property control?

Explanation

In a flex container, `justify-content` distributes and aligns items along the main axis, such as spacing them at the start, center, or end. The main axis depends on the `flex-direction` setting; the cross axis is controlled by `align-items` and related properties.

Submit

20. What does the adjacent sibling combinator (+) select?

Explanation

The adjacent sibling combinator (`+`) selects the element that immediately follows another element and shares the same parent. It matches only that next sibling, not all later siblings, descendants, or direct children generally.

Submit
×
Saved
Thank you for your feedback!
View My Results
Cancel
  • All
    All (20)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
What is the difference between margin and padding?
What does the CSS @media rule enable?
Which combinators can you use to select child elements in CSS?
The box-sizing property set to border-box includes which dimensions?
What does the CSS transform property allow?
Which property makes text wrap within a container?
In CSS Grid, what does the fr unit represent?
The :not() pseudo-class is used to select which elements?
What does the flex-grow property do?
Which selector matches elements with a specific attribute value?
Which CSS selector has the highest specificity?
In grid layout, what does grid-auto-flow property determine?
Which property controls the stacking order of positioned elements?
What does the CSS calc() function allow you to do?
The :nth-child(2n) pseudo-class selector targets which elements?
Which CSS property defines the gap between grid items?
What is the default value of the display property for a div element?
Which value of the position property removes an element from the...
In flexbox, what does the justify-content property control?
What does the adjacent sibling combinator (+) select?
play-Mute sad happy unanswered_answer up-hover down-hover success oval cancel Check box square blue
Alert!