<formaction="/submit"method="post"><!-- Form elements --> <labelfor="username">Username:</label> <inputtype="text"id="username"name="username"> <buttontype="submit">Submit</button></form>
<!-- GET: untuk data non-sensitif --><formmethod="get"><!-- POST: untuk data sensitif/upload file --><formmethod="post">
Enctype
<!-- Default --><formenctype="application/x-www-form-urlencoded"><!-- Untuk upload file --><formenctype="multipart/form-data"><!-- Untuk plain text --><formenctype="text/plain">
<!-- Validasi dengan regex --><inputtype="text"pattern="[A-Za-z]{3}">
Custom Validation Messages
<inputtype="text"requiredoninvalid="this.setCustomValidity('Mohon isi field ini')"oninput="this.setCustomValidity('')">
3.2 Input Elements
3.2.1 Text Input
<!-- Text input biasa --><inputtype="text"name="username"placeholder="Masukkan username"><!-- Password --><inputtype="password"name="password"placeholder="Masukkan password"><!-- Text area --><textareaname="komentar"rows="4"cols="50">Tulis komentar di sini...</textarea>
<!-- Email --><inputtype="email"name="email"><!-- URL --><inputtype="url"name="website"><!-- Number --><inputtype="number"min="0"max="100"step="5"><!-- Range --><inputtype="range"min="0"max="100"value="50"><!-- Date --><inputtype="date"><inputtype="datetime-local"><inputtype="month"><inputtype="week"><inputtype="time"><!-- Color --><inputtype="color"><!-- Search --><inputtype="search"name="q"><!-- Tel --><inputtype="tel"pattern="[0-9]{12}">
3.3.2 Form Validation Attributes
<!-- Required field --><inputtype="text"required><!-- Minimum/Maximum Length --><inputtype="text"minlength="3"maxlength="10"><!-- Number Range --><inputtype="number"min="1"max="100"><!-- Pattern Matching --><inputtype="text"pattern="[A-Za-z]{3}"><!-- Custom Error Message --><inputtype="email"title="Masukkan email yang valid">
3.3.3 Autocomplete
<!-- Enable/Disable Autocomplete --><formautocomplete="on"> <inputtype="text"autocomplete="off"></form><!-- Specific Autocomplete Types --><inputtype="text"autocomplete="name"><inputtype="text"autocomplete="email"><inputtype="text"autocomplete="street-address"><inputtype="text"autocomplete="tel">