form標(biāo)簽、input和button、table標(biāo)簽

form標(biāo)簽:跳轉(zhuǎn)頁面(HTTP POST 請求)

  • form表單里必須要有input “提交” 按鈕,否則無法提交這個form,除非你用JS
  • form標(biāo)簽一般是用來發(fā) POST 請求的
<a href="index2.html" target="">link</a>
<iframe src="#" frameborder="0" name="xxx"></iframe>
<form action="users" method="POST" target="xxx">
  <input type="text" name="username">
  <input type="password" name="password">
  <input type="submit" value="提交">
</form>
Content-Type
  • POST請求: name會帶到第四部分作為它的key,而GET不會,而是將其作為查詢參數(shù)顯示
  • file協(xié)議不支持POST
  • HTTP協(xié)議不安全,網(wǎng)絡(luò)一旦被監(jiān)聽,用戶名和密碼就會泄露

input和button

  • 如果只寫了一個button,沒有寫type,那么會自動升級為一個提交按鈕,默認(rèn)是submit,如果寫了,就按照type執(zhí)行
<button>button</button>
<button type="button">button</button>
  • submit是唯一能夠確定form表單能否點擊提交的按鈕,而button只是一個普通的按鈕,和提交沒有關(guān)系
<input type="submit" value="button">
<input type="button" value="button">
  • checkbox: 多選框勾選。
    label表示點擊文字即勾選,用途是和一個input關(guān)聯(lián),同屬于一個checkbox的選項用同一個name。
<input type="checkbox" id="xxx"><label for="xxx">自動登錄</label>
或
<label>用戶名<input type="text" name="username"></label>
<label>密碼<input type="password" name="password"></label>
<label><input type="checkbox" name="login" value="autologin">自動登錄</label>
<label><input type="checkbox" name="login" value="password">記住密碼</label>
  • radio: 單選框圓點勾選。
<label><input type="radio" name="owner" value="yes">Yes</label>
<label><input type="radio" name="owner" value="no">No</label>
  • select: 分組。value為空或者不寫則無選項;disabled不可選;selected默認(rèn)勾選。
<select name="group" multiple>
  <option value="">-</option>
  <option value="1">第一組</option>
  <option value="2">第二組</option>
  <option value="3" disabled>第三組</option>
  <option value="4" selected>第四組</option>
</select>
  • textarea: 多行文本。用戶可以填寫多行文本,默認(rèn)可以隨意調(diào)節(jié)寬高,可以用CSS設(shè)置固定resize:none; cols列數(shù); rows行數(shù)。
<textarea style="resize:none; width:300px; height:300px;" name="多行文本" cols="30" rows="10"></textarea>

區(qū)別:input沒有子元素,而button有子元素(span等)

table標(biāo)簽:很少用

  • HTML規(guī)定,table標(biāo)簽里只能有三個元素:thead,tbody 和 tfoot。
<body>
  <table>
    <thead></thead>
    <tbody></tbody>
    <tfoot></tfoot>
  </table>
</body>
  • thead, tbody, tfoot 三個元素順序是固定的,代碼順序亂了瀏覽器也是按順序顯示。
  • 沒有寫tbody瀏覽器會自動補上,thead 或 tfoot沒寫就默認(rèn)顯示tbody內(nèi),都沒寫就按照寫的順序顯示。
  • border默認(rèn)邊框是有空隙的,加上collapse邊框就是實線。
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title></title>
  <style>
    table{
      border-collapse:collapse;
    }
  </style>
</head>
<body>
  <table border=1>
    <colgroup>
      <col width=70>
      <col bgcolor=yellow width=60>
      <col width=60>
      <col width=60>     
    </colgroup>
    <thead>
      <tr>
        <th>項目</th><th>姓名</th><th>班級</th><th>分?jǐn)?shù)</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <th></th><td>張三</td><td>一班</td><td>94</td>        
      </tr>
      <tr>
        <th></th><td>李四</td><td>二班</td><td>96</td>        
      </tr>      
      <tr>
        <th>平均分</th><td></td><td></td><td>95</td>        
      </tr>
    </tbody>
    <tfoot>
      <tr>
        <th>總分</th><td></td><td></td><td>190</td>        
      </tr>
    </tfoot>
  </table>
</body>
</html>
默認(rèn)border

加上collapse
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容