兩種姓名和密碼的書寫方式有什么本質的不同嗎
<form>
姓名:
<input type="text" name="myName">
<br/>
密碼:
<input type="password" name="pass">
</form>
和下面的姓名、密碼部分的書寫方式有什么不同嗎
<form method="post" action="save.php">
<label for="username">用戶名:</label>
<input type="text" name="username" />
<label for="pass">密碼:</label>
<input type="password" name="pass" />
</form>
2015-10-03
沒有本質上的不同,如果說有區別,后者用了lable標簽,但lable標簽你用錯了,不會有任何效果。
其定義和用法:
<label> 標簽為 input 元素定義標注(標記)。
label 元素不會向用戶呈現任何特殊效果。不過,它為鼠標用戶改進了可用性。如果您在 label 元素內點擊文本,就會觸發此控件。就是說,當用戶選擇該標簽時,瀏覽器就會自動將焦點轉到和標簽相關的表單控件上。
<label> 標簽的 for 屬性應當與相關元素的 id 屬性相同。
2015-10-21
首先為什么“用戶名:”用<label>標簽包?。縧abel標簽的作用?
?????? <label for="username">用戶名:</label>
? ? ? ?<input type="text" id="usename"?name="username" />
你可以試試去掉<label>標簽,或者用<span><p>等標簽包住“用戶名:”最終呈現在頁面也是一樣的效果,那回到第一個問題為什么用<lable>標簽包住???????? 因為label標簽是用來提示用戶體驗的這個作用,直白點說當你點擊“用戶名:”這幾個字時,輸入框同樣會出現輸入的光標,也就是不用非得點擊輸入框里面才能輸入文字。
第二個就是<label>標簽的用法:標簽的for屬性的值等于對應的input(輸入框)的id!這樣就把輸入框和用戶名聯系起來了
<label for=""></label>
<input type="" id="" name="">