Menu
Coddy logo textTech

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: input is a special tag, it does not require a closing tag!

challenge icon

Challenge

Easy

Create an HTML document that includes a form with the following text input fields:

  1. A text input with the name “firstname”.
  2. 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 text
  • name: 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>
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals