2011-08-28 52 views

回答

6

我在Chrome的開發者工具拉昇源,和這裏的至少谷歌Chrome瀏覽器如何解釋你的源:

<div class="ban_hdr"> 
    <p> 
     Which of the following are correct? abc abc 
    </p> 
    <p>Test this code</p> 
    <p></p> 
    <p>Which of the following are correct? pqr pqr</p> 
</div> 

一個<p>標籤可以」 t嵌套在<p>標籤中。所以,這顯然是Chrome對你的含義的最好詮釋。去搞清楚。當你使用無效的代碼時,期待無意義的結果。

4

由於您P標記嵌套(它們不允許),瀏覽器將它們重新排列爲:

<p> Which of the following are correct? abc abc </p> 
<p>Test this code</p> 
<p></p> 
<p>Which of the following are correct? pqr pqr</p> 

它現在很容易明白爲什麼結果是4

3

您不能嵌套p標籤。此HTML的呈現輸出爲:

<div class="ban_hdr"> 
    <p> 
     Which of the following are correct? abc abc</p> <!-- 1 --> 
     <p>Test this code</p> <!-- 2 --> 
    <p></p> <!-- 3 --> 
<p>Which of the following are correct? pqr pqr</p> <!-- 4 --> 
</div> 
相關問題