Sử dụng bộ chọn CSS:chỉ đọc để chọn các phần tử ở chế độ chỉ đọc.
Ví dụ
Bạn có thể thử chạy mã sau để triển khai:bộ chọn chỉ đọc:
<!DOCTYPE html>
<html>
<head>
<style>
input:read-only {
background-color: blue;
color: white;
}
</style>
</head>
<body>
<form>
Subject: <input type = "text" name = "subject" value = "Maths"><br>
Student: <input type = "text" name = "student" readonly value = "Amit"><br>
</form>
</body>
</html>