em vs rem in CSS

In CSS, em and rem represent relative units that display the scalable and responsive results.

  • em: It is relative to the font size of the parent. For example, if a parent font size is 20px, then 2em will equal 40px.
  • rem: It’s relative to root element font size, usually <html>. For example, if root font size is 16px, then 1rem equals 16px.

Related

CSS Combinators

A combinator is a sign that explains the relationship between selectors.

CSS Selectors

CSS selectors are used to “find” (or select) the HTML elements you want to style.

Minify CSS and JavaScript

发布博客时,压缩CSS和JavaScript文件的大小,能提升网页的加载速度,这里介绍使用cssnano和Terser工具来压缩。