Learning HTML - Day 6

  Today is 29th January 2021 and it is my fourth day to learn HTML 🙋

Day 6 - Time 8.00 pm - 9.15 pm

Day 1      Day 2
<form> Defines an HTML form for user input
<input> Defines an input control
<textarea> Defines a multiline input control (text area)
<label> Defines a label for an <input> element
<fieldset> Groups related elements in a form
<legend> Defines a caption for a <fieldset> element
<select> Defines a drop-down list
<optgroup> Defines a group of related options in a drop-down list
<option> Defines an option in a drop-down list
<button> Defines a clickable button
<datalist> Specifies a list of pre-defined options for input controls
<output> Defines the result of a calculation

An HTML form is used to collect user input. The user input is most often sent to a server for processing. It is a section of a document containing normal content, markup, special elements called controls (checkboxes, radio buttons, menus, etc.), and labels on those controls.

The form itself is not visible. Also note that the default width of an input field is 20 characters.

Code - 
<html>
<head>
<title>My webpage</title>
</head>
<body>
<form>
<input type="text" value="Malay">
</form>
</body>
</html>


Syntax - <form> ...form elements...</form>

The <form> element is a container for different types of input elements, such as: text fields, checkboxes, radio buttons, submit buttons, etc.

<input type="text"> Displays a single-line text input field
<input type="radio"> Displays a radio button (for selecting one of many choices)
<input type="checkbox"> Displays a checkbox (for selecting zero or more of many choices)
<input type="submit"> Displays a submit button (for submitting the form)
<input type="button"> Displays a clickable button

<html>
<head>
<title>My webpage</title>
</head>
<body>
<p><h2>All input types 5 types (text, radio, checkbox, submit, button)</h2></p>
<form>
Input type radio
<input type="radio"><br>
Input type text
<input type="text"><br>
Input type button
<input type="button"><br>
Input type checkbox
<input type="checkbox"><br>
Input type submit
<input type="submit">
</form>
</body>
</html>


The <label> Element
Notice the use of the <label> element in the example above.

The <label> tag defines a label for many form elements.

The <label> element is useful for screen-reader users, because the screen-reader will read out loud the label when the user focus on the input element.

The <label> element also help users who have difficulty clicking on very small regions (such as radio buttons or checkboxes) - because when the user clicks the text within the <label> element, it toggles the radio button/checkbox.

The for attribute of the <label> tag should be equal to the id attribute of the <input> element to bind them together.

<html>
<head>
<title>My webpage</title>
</head>
<body>
<form>
<input type="text" id="fname" name="fname">
<label for="fname">First Name</label>
</form>
</body>
</html>



Comments

Popular posts from this blog

Jquery