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 / 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 / Syntax

HTML Tutorial / Syntax

Learn the essential rules of HTML syntax, including elements, tags, attributes, void elements, comments, nesting, and the structure of a complete HTML document.

HTML Tutorial / Links: Paths, Page Fragments, and Email

HTML Tutorial / Links: Paths, Page Fragments, and Email

Create HTML links with absolute or relative URLs, jump to a document fragment, and add email, new-tab, or download links. Learn what to verify before publishing.

HTML Tutorial / Lists: ul, ol, dl, and Nested Lists

HTML Tutorial / Lists: ul, ol, dl, and Nested Lists

Choose the right HTML list for ordered items, unordered items, and name–description pairs. Try a complete example, custom numbering, and correctly nested lists.

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 / 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 / Form Validation with required, Length, and Range Limits

HTML Tutorial / Form Validation with required, Length, and Range Limits

Apply built-in required, length, and numeric constraints, test error states, and understand why server-side validation remains necessary.

HTML Tutorial / Group Images and Captions with figure and figcaption

HTML Tutorial / Group Images and Captions with figure and figcaption

Use figure and figcaption to keep an image and its visible explanation together, and distinguish captions from image alt text.

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 / Divide a Page with Semantic Elements

HTML Tutorial / Divide a Page with Semantic Elements

Learn when to use header, nav, main, article, section, aside, and footer, then build a complete page whose regions and in-page links work together.