Reputation: 19572
So em
and percentage
are both defined in relation to something else.
E.g. with text-indent
it is in relation to the width of the paragraph. Else where (I think font) in relation to the browser's default size.
So why do both em
an percentage
exist if they do exactly the same thing?
Are the items which they are relative in each case (examples I have already given) documented somewhere? How do I know in each case with what the value is relative to?
Upvotes: 0
Views: 88
Reputation: 723719
They don't do the same thing. Ems are relative to the element's font size, unless they're specified on the font size in which case it's relative to the parent's font size.
Percentage values are relative to other specific values — which of these varies from property to property. Sometimes, percentages may not even be applicable to certain properties, such as borders, whereas ems can be used anywhere that takes a length quantity.
Upvotes: 5