<div class="selection">
<span class="myspan">Selam</span>
</div>
.selection{
width:200px;
font-size:18px;
}
.myspan{
font-size:220%;
display:block;
width: 50%;
}
i have html and css as above. My question is: When the Css parsed is performed, is the "Calculated value" 50% or 39.6px for the font size(myspan)?
Your question is a little confusing, but I'll try to cover the details off as I think you're asking.
First, I think you mean the "Computed" value rather than the "Calculated" value. You also ask in a comment about the "Used" value, and to get a full picture we also need to cover some other values, the "Specified" value, the "Resolved" value and the "Actual" value.
Now taking the
font-sizefirst, we have for the .myspan element(The resolved value for
font-sizeis the computed value)(Always the same as the computed value for
font-size)(The CSS pixels will be converted to device pixels. some other approximations may be made based on the available fonts and the closest renderable number on the device is used)
For the
width, things work slightly differently(The pixel length is not known at computed value time because the layout hasn't happened at this step)
(The layout is done and the pixel value is determined)
(The resolved value for
widthis the used value)(As with font-size, the CSS pixels will be converted to device pixels and the closest renderable number on the device is used)
Now, what causes confusion is that when you use
getComputedStyle()in JavaScript, or inspect the "Computed Values" tab in the browsers' developer tools, you don't get the "Computed" values for the element - You get the "Resolved" values for the element.For
getComputedStyle(), this is just an historical anomaly that exists for backward compatibility reasons. Why the developer tools also report the Resolved value, I don't know.