HTML CSS examples for HTML Tag:input
The checkbox type of the input element creates a check box that allows the user to make a true/false choice.
This value for the type attribute supports the additional attributes shown in the following table.
Attribute | Description |
---|---|
checked | If applied, this attribute ensures that the check box is checked when initially displayed to the user or when the form is reset. |
required | Specifies that the user must check the check box for the purposes of input validation. |
value | Specifies the data value that is submitted to the server when the check box is checked; defaults to on. |
The following code shows how to use an input Element to Create a Check Box
<!DOCTYPE html> <html> <head> <title>Example</title> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"> </head> <body> <form method="post" action="http://example.com/form"> <p> <label for="name"> Name: <!--from ww w . j av a 2s . com--> <input value="java2s.com" id="name" name="name"> </label> </p> <p> <label for="password"> Password: <input type="password" placeholder="Min 6 characters" id="password" name="password"> </label> </p> <p> <label for="fave"> Fruit: <input value="CSS" id="fave" name="fave"> </label> </p> <p> <label for="veggie"> Are you vegetarian: <input type="checkbox" id="veggie" name="veggie"> </label> </p> <input type="submit" value="Submit Vote"> </form> </body> </html>