$(document).ready(function () { $("form div input").focus(function () { $("form div").each(function () { $(this).css("background-color", "white"); }); $(this).parent().css("background-color", "#F2FAED"); $(this).select(); }); });As for setting the width of the div, the width attribute is probably deprecated, but setting it through the style should still work (and I believe is the preferred way). The same goes for your controls.