English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Referenzhandbuch

Vollständiges Verzeichnis der HTML-Tags

HTML: <input> readonly Eigenschaft

Die readonly-Eigenschaft des input-Elements ist ein boolesches Attribut. Wenn es vorhanden ist, wird das Eingabefeld als lesend festgelegt. Setzen Sie die readonly-Eigenschaft, um zu verhindern, dass der Benutzer den Wert ändert, bis andere Bedingungen erfüllt sind.

 HTML <input> Tag

Online-Beispiel

HTML-Formular mit lesendem Eingabefeld:

<!DOCTYPE html>
<html>
<head>
<title>HTML:<input> readonly-Eigenschaft - Grundlagen-Tutorial-Website(oldtoolbag.com)</title>
<body>
<form action="action_page.php">
  E-Mail: <input type="text" name="email"><br>
  Land: <input type="text" name="country" value="Norway" readonly><br>
  <input type="submit" value="Submit">
</form>
</html>
Test it out ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the readonly attribute.

Definition and Usage

The readonly attribute is a boolean attribute.

If present, specifies the input field as read-only.

Read-only input fields cannot be modified (but users can tab through them, highlight, and copy text from them).

You can set the readonly attribute to prevent users from changing the value until certain conditions are met (such as checking a checkbox, etc.). Then, JavaScript can remove the read-only value and make the input field editable.

Note:Forms will still submit read-only input fields, but will not submit disabled input fields!

HTML 4.01 With HTML5Differences

None.

Differences between HTML and XHTML

In XHTML, attribute abbreviation is prohibited, the readonly attribute must be defined as <input readonly="readonly" />。

Syntax

<input readonly>
 HTML <input> Tag