Edit This Code:
<!DOCTYPE html>
<html>
<head>
<style>
input[type=text] {
    width: 100%;
    padding: 12px 20px;
    margin: 8px 0;
    box-sizing: border-box;
    border: 1px solid #555;
    outline: none;
}


input[type=text]:focus {
    background-color: lightblue;
}

</style>
</head>
<body>

<p>In this example, we use the :focus selector to add a background color to the text field when it gets focused (clicked on):</p>

<form>
  <label for="fname">First Name</label>
  <input type="text" id="fname" name="fname" value="John">
  <label for="fname">Last Name</label>
  <input type="text" id="lname" name="lname" value="Doe">
</form>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy