+1 vote
in CSS by
How do you specify units in the CSS?. What are the different ways to do it?

1 Answer

0 votes
by
There are different ways to specify units in CSS like px, em, pt, percentage (%). px(Pixel) gives fine-grained control and maintains alignment because 1 px or multiple of 1 px is guaranteed to look sharp. px is not cascade. em maintains relative size. you can have responsive fonts. Em, will cascade 1em is equal to the current font-size of the element or the browser default. If u sent font-size to 16px then 1em = 16px. The common practice is to set default body font-size to 62.5% (equal to 10px).

pt(point) are traditionally used in print. 1pt = 1/72 inch and it is a fixed-size unit.

%(percentage) sets font-size relative to the font size of the body. Hence, you have to set the font-size of the body to a reasonable size.

Related questions

+2 votes
asked Jul 6, 2021 in CSS by rajeshsharma
0 votes
asked Feb 14 in CSS by DavidAnderson
...