Text Inputs
Part of the Fundamentals section of Coddy's HTML journey — lesson 36 of 60.
In HTML, text inputs are used to create form fields where users can enter text. There are various types of text inputs, each designed for different kinds of text-based data. The most common type is the single-line text input, created using the <input> tag with the type attribute set to "text".
Here's the basic syntax for creating a text input in HTML:
<input type="text" name="fieldname"><input>: The tag that defines the input field.type="text": An attribute that specifies the input type as text.name: An attribute that gives the input field a name, which is used to identify the data when the form is submitted.
Note:
inputis a special tag, it does not require a closing tag!
Challenge
EasyCreate an HTML document that includes a form with the following text input fields:
- A text input with the name “firstname”.
- A text input with the name “lastname”.
Cheat sheet
Text inputs are created using the <input> tag with type="text":
<input type="text" name="fieldname">type="text": Specifies the input type as textname: Identifies the data when the form is submitted
Note: <input> is a self-closing tag and does not require a closing tag.
Try it yourself
<!DOCTYPE html>
<html>
<body>
<!-- Write code here -->
</body>
</html>This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Fundamentals
2Text and Formatting
HeadingsParagraphsLine BreaksBold and Italic TextBold and Italic AgainRecap - Formatting8Forms and Inputs Part 1
Form BasicsText InputsInput AttributesPassword FieldLabels for InputsRecap - Basic Form11Event Registration Page
Project OverviewHeader Section9Forms and Inputs Part 2
Radio ButtonsCheckboxesDropdownsButtonsButtons in FormsRecap - Forms #1Recap - Forms #2