Select an input field when it gets focus: - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:focus

Description

Select an input field when it gets focus:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
input:focus {<!--from www.  j a  v  a  2  s.  co m-->
    background-color: yellow;
}
</style>
</head>
<body>

<p>Click inside the text fields to see a yellow background:</p>

<form>
First name: <input type="text" name="myId"><br>
Last name: <input type="text" name="lastname">
</form>

</body>
</html>

Related Tutorials