Example

Form Input in HTML

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Form Input in HTML</title>
</head>
<body>

<h1>Demo: Form Input in HTML</h1><br>

    <h2>Enter the details:</h2>
<!-- To demo the usuage of input type as "text" -->
    <form>
            <label for="fname">Name:</label> <br>
            <input type="text" id="fname" name="fname" placeholder="Enter the Name">
            <br>
            <label for="lname">Surname:</label><br>
            <input type="text" id="lname" name="lname" placeholder="Enter the Surname">
            <br>
            <label for="phone">Phone#:</label><br>
            <input type="text" id="phone" name="phn" placeholder="Enter the phone#">
            <br>
            <label for="cname">Country:</label><br>
            <input type="text" id="cname" name="cname" value="India">
    </form>


    <h2>Choose your favorite Web language:</h2>
<!-- To demo the usuage of input type as "radio" -->
    <form>
        <input type="radio" id="html" name="fav_language" value="HTML">
        <label for="html">HTML5</label><br>
        <input type="radio" id="css" name="fav_language" value="CSS">
        <label for="css">CSS3</label><br>
        <input type="radio" id="javascript" name="fav_language" value="JavaScript">
        <label for="javascript">JavaScript</label>
    </form>
    
    <h2>Choose your vehicle you own:</h2>
<!-- To demo the usuage of input type as "checkbox" -->
    <form>
        <input type="checkbox" id="vehicle1" name="vehicle1" value="Bike">
        <label for="vehicle1"> I own a bike</label><br>
        <input type="checkbox" id="vehicle2" name="vehicle2" value="Car">
        <label for="vehicle2"> I own a car</label><br>
        <input type="checkbox" id="vehicle3" name="vehicle3" value="Boat">
        <label for="vehicle3"> I own a boat</label>
    </form><br>

    <h2>Choose your Car Make:</h2>
<!-- To demo the usuage of "select" and "option" tags -->
    <label for="cars">Car brands:</label>

    <select id="cars" name="cars">
        <option value="volvo">Volvo</option>
        <option value="saab">Tata</option>
        <option value="fiat">Fiat</option>
        <option value="audi">Audi</option>
    </select><br><br>

<!-- To demo the usuage of "action" and "target" attributes of form tag -->
    <form action="/notes/examples/html/output/thankYou.html" target="_blank">
        <input type="submit" value="Submit">
    </form><br><br>

</body>
</html>
                    
                    

Output

View original