为什么这种匿名块框的字体大小不一样

时间:2016-04-03 07:14:55

标签: html css



body {font-size: 40px;}
p {font-size: 12px;}
div, span {font-size: 20px;}

<h6>Why font size of before is inherited from p, while that of after is inherited from div</h6>
<p>before<div>content</div>after</p>
<hr>
<h6>This result is acceptable</h6>
<p>before<span>content</span>after</p>
&#13;
&#13;
&#13; 请参阅匿名阻止框的规范,请点击此链接:http://www.w3.org/TR/CSS2/visuren.html#anonymous-block-level

1 个答案:

答案 0 :(得分:1)

P元素中唯一有效的内容是phrasing content,而DIV不是短语内容。您的HTML无效,对浏览器毫无意义,因此产生的内容没有理由符合您的期望。

span是一个措辞内容,这就是第二部分根据您的期望运作的原因。