看代码:
效果如下:
统计一下
a 和 div 的 text-align(a 没有)、font-size、font-weight 都从 body 那里得到了继承;
但是 color 只是 div 从 body 继承了,而 a 没有听其的话;
text-decoration 表面上看 a 和 div 都从 body 继承了,但也要看情况,如果是示例中的 text-decoration:line-through 的确是继承了,但 text-decoration:none 的话,a 就不会继承了。
扩展一下
大多数像布局的属性,比如 float、width、height、border、background 等都不会被继承;而大多数像样式的属性,比如 color 等都会被继承。