Giới thiệu
Để chọn phần tử đang được focus, sử dụng bộ chọn :focus.
Ví dụ
<!DOCTYPE html>
<html>
<head>
<style>
input:focus {
background-color: green;
}
</style>
</head>
<body>
<form action="">
Môn học <input type="text" name="subject"><br>
Học sinh: <input type="text" name="student"><br>
Tuổi: <input type="number" name="age"><br>
<input type="submit" value="Gửi">
</form>
</body>
</html>