/

HTML / CSS / JavaScript Tutorial

HTML Standard attribute: readonly

[this page | pdf | back links]

The HTML readonly attribute indicates whether an <input> or <textarea> element is read-only.

 

Valid attribute values (when used with <input> and <textarea> elements) include:

 

Value

Description

readonly

Indicates that input box is read-only

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
Set using HTML:<br>
<input type="text" value="inputtable" ><br>
<input type="text" value="readonly" readonly="readonly">

<br><br>Set using JavaScript:<br>
<input id="x1" type="text" value="readonly">

<script>
document.getElementById("x1").readOnly = true;
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes


Desktop view | Switch to Mobile