WEB-DEVELOPMENT-FOUNDATION practice question 10 of 15

Which CSS unit is a relative unit?

Full set: 75 questions
Answer options
A: px
B: Q
C: Opt
D: % Correct answer
Correct Answer:
D. %
Explanation

The percentage (%) unit is a relative unit in CSS. Its value is always calculated in relation to another value, typically a property of the parent element. For example, if an element's width is set to 50%, it will occupy half the width of its containing parent element. This relativity allows for the creation of fluid and responsive layouts that adapt to different container sizes, which is a fundamental concept in modern web design.

Why Incorrect

A. px (pixels) is an absolute unit. While its physical size depends on screen density, in CSS it represents a fixed value, not one relative to another element's property.
B. Q (quarter-millimeters) is an absolute physical unit of length, defined as 1/4th of a millimeter, and does not change relative to other elements.
C. Opt is not a valid CSS length unit. It may be a typographical error for pt (points), which is an absolute unit.

References

1. Mozilla Developer Network (MDN) Web Docs: The CSS data type documentation categorizes units. The percentage (%) is listed under "Relative length units," while px and Q are listed under "Absolute length units."

Source: MDN Web Docs, - CSS: Cascading Style Sheets. See sections on "Relative length units" and "Absolute length units."

2. W3C (World Wide Web Consortium) Specification: The official CSS Values and Units Module Level 4 specification defines the behavior of all CSS units.

Source: W3C Candidate Recommendation, 29 September 2022, "CSS Values and Units Module Level 4," Section 6.2, "Relative Lengths: the ‘’ type and ‘’ type." This section explicitly defines percentages as relative values. Section 6.1, "Absolute Lengths," defines px and Q.

3. MIT OpenCourseWare: Course materials for web programming often cover the distinction between absolute and relative units as a foundational concept.

Source: MIT OpenCourseWare, 6.170 Software Studio, Fall 2005, Lecture 10: CSS. The lecture notes distinguish between absolute units (e.g., px, pt) and relative units (e.g., em, %).

Scroll to Top