AD JB Toolbox 01 EN

HTML Tutorial / Use textarea, select, option, and button

Use textarea for multi-line text, select with option for a prepared list of choices, and button for an explicit action. These elements have different ways of holding values and submitting a form.

Enter several lines with textarea

A textarea's initial value goes between its opening and closing tags rather than in a value attribute.

<label for="message">Your message</label>
<textarea id="message" name="message" rows="5" cols="40"></textarea>

rows and cols influence the initial displayed size; CSS can make the control fit the available width. The name is needed if its content should be submitted. Text between the tags becomes a real initial value. If you only want to show an example, use a placeholder as a supplementary hint and keep the label. Use textarea instead of a single-line input when readers need room to edit a longer response.

Offer choices with select and option

<label for="topic">Topic</label>
<select id="topic" name="topic">
  <option value="order">Orders</option>
  <option value="delivery">Delivery</option>
  <option value="other">Other</option>
</select>

The screen shows “Orders,” but the submitted value is order. id="topic" connects the control to its label, while name="topic" names the submitted data. Choose option values that match what the server expects. With no interaction, the first option is selected. If users must consciously choose, start with <option value="">Choose a topic</option> and add required to select. If a sensible default exists, the first real option may be preferable.

State each button's type

Inside a form, a button defaults to submission. Use type="button" for a different scripted action so it does not submit accidentally.

<form action="" method="get">
  <label for="note">Note</label>
  <textarea id="note" name="note" rows="4"></textarea>
  <button type="submit">Submit</button>
  <button type="reset">Reset entries</button>
</form>

Opening this in a browser lets you submit to the current URL and inspect the query string without a server. Reset returns controls to their initial values; it does not always make them empty. If a textarea began with text, reset restores that text. A reset button can erase someone's work, so include it in a real form only when it has a clear purpose and placement. See the MDN HTML element reference for individual attributes.

type="button" prevents form submission but does not create a new action by itself. Without a script connected to it, clicking that button does nothing. Distinguish HTML's built-in submit and reset actions from actions that need a script.

More in This Category
HTML Tutorial / Headings and Paragraphs

HTML Tutorial / Headings and Paragraphs

Learn when to use h1–h6 headings, p paragraphs, and br line breaks in HTML. Examples show document hierarchy, browser output, and common mistakes.

HTML Tutorial / Responsive Images: srcset, sizes, and picture

HTML Tutorial / Responsive Images: srcset, sizes, and picture

Offer image resolutions with srcset and sizes, and switch crops with picture. Downloadable files let you test the examples in a browser.

HTML Tutorial / Use textarea, select, option, and button

HTML Tutorial / Use textarea, select, option, and button

Create multi-line fields, selection lists, and form buttons while understanding initial values, submitted values, and reset behavior.

HTML Tutorial / Text Semantics: Emphasis, Quotations, Abbreviations, and Code

HTML Tutorial / Text Semantics: Emphasis, Quotations, Abbreviations, and Code

Learn when to use HTML em, strong, q, blockquote, abbr, code, and kbd. Examples show how each element conveys meaning rather than just changing the appearance of text.

HTML Tutorial / What Is HTML and What Does It Do on a Web Page?

HTML Tutorial / What Is HTML and What Does It Do on a Web Page?

HTML gives web content structure and meaning. Learn how it differs from CSS and JavaScript, see how basic markup appears in a browser, and make your first HTML file.

HTML Tutorial / Add Placeholder Text to Form Fields

HTML Tutorial / Add Placeholder Text to Form Fields

Learn how to add placeholder hints to HTML input and textarea fields without confusing them with labels or initial values. Includes a complete form example, required-field checks, and an explanation of empty values in submitted data.

HTML Tutorial / Images: img, Alt Text, and Dimensions

HTML Tutorial / Images: img, Alt Text, and Dimensions

Add an image with HTML img, write useful alternative text, and set width and height correctly. A downloadable example helps you test file paths and sizing.

HTML Tutorial / Choose Input Types for Email, Numbers, Dates, and Choices

HTML Tutorial / Choose Input Types for Email, Numbers, Dates, and Choices

Choose input types based on the value being collected and understand how checkboxes and radio groups behave when submitted.

HTML Tutorial / Form Structure and GET vs. POST

HTML Tutorial / Form Structure and GET vs. POST

Understand how form action, method, and control names determine where form values go, and when GET or POST is appropriate.

HTML Tutorial / Table Basics: table, tr, th, and td

HTML Tutorial / Table Basics: table, tr, th, and td

Build a basic HTML data table with rows and header or data cells, then organize its headings and body without using tables for page layout.