p标签里的div

2012-03-27 09:50:24

昨天去论坛看到一位童鞋提到这么一个问题
<html>
<head>
<title>关联样式选择器</title>
<style>
p { color:green; font-size:1cm }
p.one { color:red; font-size:2cm; }
div .one { color:yellow; font-size:3cm; background-color:red; }
</style>
</head>
<body>
<p class="one">这是被定义过的</p>
<p>这是没定义过的</p>
<div>
<div class="one">这是被定义过的</div>
</div>
</body>
</html>
为什么把div 换成P之后 就显示不出来了?谁能告诉我一下么?
俺也没遇到过,于是找了些资料,现学现卖给他
55U:
W3c的html4.0.1明确规定P标签是不能包含块元素的孩子的。 原文: The P element represents a paragraph. It cannot contain block-level elements 原文地址: http://www.w3.org/TR/html401/struct/text.html#edef-P 如果含有浏览器会解析成 <p></p> <div></div> <p></p>;
可以用chrome查看一下 另外p.one和p .one是不一样的,注意中间有个空格 p.one可以简写成.one p .one是指p元素下的子元素.one。
 
|