HTML中表單form標(biāo)簽的基本語法:
<form action="save.php" method="get"><!--methode有兩種值get/post,不填寫默認(rèn)是get-->
<label for="username">賬號</label>
<input id="username" type="text" name="username" placeholder="輸入用戶名">
<label for="password">密碼</label>
<input id="password" type="password" name="password" placeholder="輸入密碼">
<button>提交</button>
</form>
需要注意的事項:
- form表單的屬性中,所以有需要打包提交到一個后臺地址的input元素必須包裹在一對form標(biāo)簽內(nèi)。
- action的值是form提交到的后臺服務(wù)器地址。
- method的值代表交互的方式,分別為get和post,get是從服務(wù)器上獲取數(shù)據(jù),post是向服務(wù)器傳送數(shù)據(jù)。
- label標(biāo)簽用于input元素的文字提示,label的for屬性是指向?qū)?yīng)的input元素的id,從而使label和input綁定在一起。
本博客版權(quán)歸曾祥輝和饑人谷所有,轉(zhuǎn)載需說明來源