.box element if the parent container is 400px wide?.box { width: calc(100% - 50px); }
The calc(100% - 50px) means take the full width of the parent (400px) and subtract 50px, resulting in 350px.
.item element when the viewport width is 800px?.item { margin-left: calc(10vw + 20px); }
10vw means 10% of 800px, which is 80px. Adding 20px gives 100px total margin-left.
.header { height: calc(50% - 20); }
The value 20 has no unit like px or %. CSS requires units for numbers in calc except zero. This causes a syntax error.
:root {
--sidebar-width: 250px;
--gap: 20px;
}
.container {
width: /* fill here */;
}Option A correctly uses var(--sidebar-width) and var(--gap) with a plus sign inside calc. Other options have syntax errors.
Which statement best explains how calc() helps create accessible layouts?
Using calc() lets designers mix percentages and pixels, so layouts adjust smoothly to screen sizes. This flexibility helps users read and navigate content better on all devices.
