CSS has several units for different units such as width, margin, padding, font-size, border-width, etc.length indicates by using numerical value followed by length units such as px,dp,em,etc. It does not allow white spaces in between numerical values and length units.Length units has divided as follows
Relative units specify a length relative to another length property. Relative length units scales better between different rendering mediums.
<p><i style="color:blue; font-size:20px;">Relative units</i></p> <p style="font-size:2em">TechFunda</p> <p style="font-size:3ex">TechFunda</p> <p style="font-size:4vw">TechFunda</p> <p style="font-size:5vh">TechFunda</p> <p style="font-size:6vmin">TechFunda</p> <p style="font-size:5vmax">TechFunda</p>
In the above code snippet we have defined the relative units by giving the different unit values to display the fontsizes
output
The absolute units are fixed and a length expressed in any of these will appear as exactly that size, absolute units are not recommended for use on screen, because screen sizes vary so much. However, they can be used if the output medium is known, such as for print layout.
<body> <p><i style="color:blue; font-size:20px;">Absolute units</i></p> <p style="font-size:1cm">TechFunda</p> <p style="font-size:4mm">TechFunda</p> <p style="font-size:1in">TechFunda</p> <p style="font-size:20px">TechFunda</p> <p style="font-size:30pt">TechFunda</p> </body>
In the above code snippet we have defined the absolue units which defines the values according to their values
output
Views: 4605 | Post Order: 142