2015-06-19 38 views
2

我正在複製一個頁面,並且想知道是否需要縮進form標記,如果它嵌套在div標記中。例如正確嵌套HTML中的表單標籤

 <div class="signup-form"> 
     <form method="post"> 
      <input type="text" value="First Name"> 
      <input type="text" value="Last Name"> 
     </form> 

或者我不寫縮進就寫。例如

 <div class="signup-form"> 
     <form method="post"> 
     <input type="text" value="First Name"> 
     <input type="text" value="Last Name"> 
     </form> 

在此先感謝您。

+0

您使用的是什麼IDE? –

+0

我正在使用Sublime2。編寫HTML5代碼。 – eagercoder

回答

3

縮進HTML沒關係,純粹是爲了可讀性。

爲了增強可讀性,在你的榜樣,我會縮進。

我會縮進,因爲form標籤包含在div標籤內。

<div class="signup-form"> 
 
    <form method="post"> 
 
    <input type="text" value="First Name"> 
 
    <input type="text" value="Last Name"> 
 
    </form> 
 
</div>

+0

是的,我會縮進 - 顯示窗體包含在div中。 – Donal

0

縮進不會影響您的標記被解釋的方式。您可以按照標準進行可讀性或您自己的風格偏好。

你也可以讓IDE格式爲你的代碼...

的Visual Studio:ctrl + k, ctrl + d

崇高的文本3:只需選擇所有行ctrl + a,然後從菜單中選擇編輯→Line→Reindent