<input type="radio" name="colour2" id="r" value="red" />Any tag can have an ID, which must be unique on the page. (Of course you wouldn't want to put in the confusing extra button.)
<label for="r"> Red</label>
<input type="radio" name="colour2" id="g" value="green" />
<label for="g"> Green</label>
<input type="radio" name="colour2" id="b" value="blue">
<label for="b"> Blue</label>
HTML 5 defines a number of new INPUT types. These are gradually
being implemented in various browsers. Meanwhile, bear in mind that any
unrecognized type defaults to "text". In addition, a text field can
have a datalist attached. In the following example, sport works like the "combo
box" above in Chrome, but not in Firefox, as of February 2015. Look at it in other browsers to determine current status.
Here is the code for this example:
<form class="ex" action="/jensen/echo.php">
My favourite sport is
<datalist id="common sports">
<option>Football</option>
<option value="Hockey"> </option>
<option>Mountain Climbing</option>
</datalist>
<input name="sport" list="common sports">
My Birthday is:
<input name="birthday" type="date">
(New type="date") or Enter as 2014-12-25<br>
How many planets?
<input type="number" name="planets" max="15">
(type="number" max="15")
<input type="submit"> <input type="reset"> </form>
You can now specify that a field (input or textarea) is required
(not blank), and to give a hint, specify a placeholder, rather than an
initial value. The placeholder is shown in grey, and disappears when
you start entering..
title customizes the error message.
<form class="ex" action="/jensen/echo.php">
<textarea name="commments"
placeholder="please make some remark" required title="Spare me 2 words!"></textarea> <input type="submit"> <input type="reset">
</form>