I have some code that I use to make my inputs have a nice background color when you put the mouse over them:
<!DOCTYPE html>
<html lang="en-us" dir="ltr">
<head>
<style type="text/css">
input[type="text"]:focus
{
background-color: #bfd0eb;
}
</style>
</head>
<body>
<form method="post">
<input type="text" name="input1" id="input1" value="" />
<input type="text" name="input2" id="input2" value="" />
</form>
</body>
</html>
This works great with XHTML 1.0 Transitional, however when I switch to HTML 5, if I click on “input2” it takes the focus off of the “input2” I click and always focuses on “input1” instead. What am I doing wrong? Thanks!
As I can’t leave a comment yet, I have added your code to jsFiddle and it works fine, http://jsfiddle.net/kuWWg/1/
If you want it to be on hover you need to use the
:hoverselector instead of:focushttp://jsfiddle.net/kuWWg/2/