Home > Web Front-end > HTML Tutorial > How to set read-only status in html

How to set read-only status in html

青灯夜游
Release: 2023-01-06 11:16:27
Original
9112 people have browsed it

In HTML, you can set the read-only status by adding the readonly attribute to the tag. The readonly attribute is a Boolean attribute that specifies that the input field or text area is in a read-only state; in the read-only state, the content cannot be modified, but the user can switch to the control through the tab key and select or copy the content.

How to set read-only status in html

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

htmlSet read-only status

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <style>
    	input,textarea{
    		width: 200px;
    	}
    </style>
  </head>
  <body>
  	<input type="text" value="测试文本-只读状态,无法编辑" readonly="readonly"/>
  	<br />
  	<textarea readonly>测试文本-只读状态,无法编辑</textarea>
  </body>
</html>
Copy after login

Rendering:

How to set read-only status in html

Description:

The readonly property is a Boolean property.

The readonly attribute specifies that the input field or text area is read-only.

In a read-only input field or text area, the content cannot be modified, but the user can switch to the control through the tab key and select or copy the content.

You can set the readonly attribute to resume the user's use of the text area until certain conditions are met (such as selecting a check box). You can then use JavaScript to remove the value of the readonly attribute to make the text area editable.

Recommended tutorial: "html video tutorial"

The above is the detailed content of How to set read-only status in html. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template