csscss-parsing

What is calculated value for font-size


<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)?


Solution

  • 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-size first, we have for the .myspan element

    For the width, things work slightly differently


    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.