What is difference between px and em in CSS?

What is difference between px and em in CSS?

px (Pixels) are considered absolute units. One px is equal to one dot on the computer screen (the smallest division of your screen’s resolution).

em is the same as the font-size of the current element (which is generally inherited). So as the font size is changed, the value of em changes as well. It is relative to other content, so it is more likely to work across screens.

In general, 1em = 16px