Some old websites, and even recent ones, that do not care about the flexible structure, still use pixel as the unit of measurement. Pixel provides us greater control of its structure and accuracy. But, nowadays, we no more have control over where the website will be displayed (as we saw in Chapter 1, Exploring Responsive Web Design), which generates the need to build flexible structures where elements may stretch and fit the dimension.
Percentage always works as it is related to the value declared in its parent element. So, if a div
tag is of size 50 percent and its parent element has 600 px, the div
tag will be of the size 300 px, as the following figure shows:
The same applies to a percentage where its parent element is of 50 percent of the actual size of an object, the div
tag that is of 50 percent of the size will look like it is 25 percent, maintaining proportions. Let's see the following figure:
But, the question is: what if we do not...