代码示例:(标识:cssref_unit_rem)
<!DOCTYPE html>
<html>
<head>
<style>
html {
  font-size:16px;
}

div {
  font-size: 3rem;
  border: 1px solid black;
}

#top-div {
  font-size: 2rem;
  border: 1px solid red;
}
</style>
</head>
<body>

<p>此文档的 font-size 是 16px。</p>

<div id="top-div">
这个 div 的 font-size 为 2rem,转换为浏览器字体大小的2倍。
<div>这个 div 元素的 font-size 为 3rem。它同时也展示出不会继承其父元素的字体尺寸。</div>
</div>

<p>rem 单位设置的 font-size 相对于浏览器的基准字体尺寸,并不从其父元素继承。</p>

</body>
</html>
运行结果: