今天我們來看看表單標籤跟屬性~
<form>是最重要的表單標籤,定義了一個表單,用來接收用戶數據並提交到伺服器。
action:指定表單提交的目標URL。
<form action="/submit-data"> </form>
method:指定表單提交的HTTP方法,一般為GET或POST。
GET:將數據附加到URL中,一般用於非敏感數據,如查詢參數。POST:將數據作為請求主體發送,適用於提交敏感資訊或大量數據。<form method="POST"> </form>
emctype="multipart/form-data":告訴瀏覽器在提交表單時如何編碼表單數據。當你需要上傳文件時,必須設定為multipart/form-data,因為它允許文件被正確打包並發送到伺服器。
<form action="/upload" method="POST" enctype="multipart/form-data">
    <input type="file" id="file" name="file">
    <input type="submit" value="上傳">
</form>
target:用來指定表單提交後或超連結被點擊後,瀏覽器應該在哪裡顯示響應內容或開啟新頁面。
<form action="/submit" method="GET" target="_blank">
    <label for="search">搜尋:</label>
    <input type="text" name="search">
    <input type="submit" value="搜尋">
</form>
今天先介紹到這裡,謝謝觀看!