CKTIS / HTML
placeholder — a hint in an empty control
The placeholder attribute supplies a short hint for an empty input or textarea. It does not set the control's value and must not replace its label.
Version: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
<input type="text" placeholder="hint">
<textarea placeholder="hint"></textarea>placeholder contains a short hint, such as a sample value or the expected format. It applies to textarea and these input types: text, search, url, tel, email, password, and number; it is not a global attribute.
The hint is intended for an empty control. Once a value is entered, it is no longer displayed; visibility while focused can depend on the browser. Do not use it instead of label: the label should identify the control even after typing begins.
The placeholder text is neither the control's value nor its default value, and does not itself satisfy required. For input, the attribute value must not contain LF or CR characters. In textarea, CRLF, CR, and LF characters in the hint are rendered as line breaks.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Placeholder example</title>
<label for="city">City</label>
<input id="city" type="text" placeholder="Krakow">
<p id="result"></p>
<script>
const city = document.getElementById('city');
document.getElementById('result').textContent =
JSON.stringify({ value: city.value, hint: city.placeholder });
</script>
</html>Result
{"value":"","hint":"Krakow"}The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.