Lecture

Advanced Usage of Tag

The input tag is most commonly used with the <form> tag.

For example, on a signup page, the input tag allows the user to enter data, and the <form> tag is used to send this data to the server.

Example of Using form Tag
<form action="/submit" method="post"> <input type="text" name="username" placeholder="Username" /> <input type="password" name="password" placeholder="Password" /> <input type="submit" value="Submit" /> </form>

More details about input forms will be covered in the next lesson.


Using the label Tag

The label tag is used to define a label for an input field, providing a description or a title.

When using the label tag, ensure that the id of the input tag matches the for attribute of the label tag.

Example of Label Tag
<label for="username">Username:</label> <input type="text" id="username" name="username" />

Validation

Validation refers to checking if the entered information is correct.

The input below uses the required attribute to validate whether the input has a value.

Validation Using Required Attribute
<input type="email" name="useremail" required />
Mission
0 / 1

Which attribute specifies a required field in the input tag?

readonly

disabled

required

hidden

Lecture

AI Tutor

Design

Upload

Notes

Favorites

Help

HTML
CSS
Loading...