WEB-DEVELOPMENT-FOUNDATION practice question 10 of 15
Which CSS unit is a relative unit?
Full set: 75 questionsThe 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.
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.
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, %).
Keep practicing
Take the free WEB-DEVELOPMENT-FOUNDATION practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other WEB-DEVELOPMENT-FOUNDATION practice questions
- Question 2What is one of the possible values of the text-align property?
- Question 3What is matched by the :hover selector?
- Question 4What describes the matches resulting from the img: first-child selector?
- Question 5Which two color definitions are valid for use with CSS? Choose 2 answers.
- Question 8What does the timelines tool of Safari Web Inspector enable a developer to do?
- Question 9Developers consider three platforms for viewport sizes. What is one of them?
