Expression Studio 4.0

Sets the style of an element when it gains focus.


:focus { sRules }

Possible values


String that specifies one or more Cascading Style Sheets (CSS) attribute/value pairs.


In an HTML document, an element must receive focus from the user in order to become active and perform its tasks. For example, users must set input focus on a link in order to follow it. Similarly, users must give a textarea focus in order to enter text into it.

There are several ways to give focus to an element:

  • Designate the element with a pointing device. Even elements that do not typically accept input, such as div and body elements, receive focus when clicked with the mouse.

    Navigate through the document with the TAB and SHIFT+TAB keys. The document's author may define a tabbing order that specifies the order in which elements will receive focus.

    Select an element through a keyboard shortcut.


The following style rule will change the background color of any element that receives input focus:

*:focus {
    background-color: #FFC;

Standards Information

This pseudo-element is defined in CSS Level 2, Revision 1 (CSS2.1) Gg721753.xtlink_newWindow(en-us,Expression.40).png.

Applies to

a, body, button, div, img, input, input type=button, input type=file, input type=image, input type=password, input type=reset, input type=submit, input type=text, span, table, td, textarea

Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.

Community Additions