HTML Form How to - Make input field readonly without changing background colour








Question

We would like to know how to make input field readonly without changing background colour.

Answer


<!DOCTYPE html>
<html>
<head>
</head>
<body>
  <input type="text" value="readonly" readonly>
  <input type="text" value="disabled" disabled>
</body>
</html>

The code above is rendered as follows: