Easy Tutorial
❮ Att Keygen Form Att Fieldset Disabled ❯

HTML onfocus Event Attribute

HTML Event Attributes

Example

Run a script when an input field gets focus:


Browser Support

All major browsers support the onfocus event attribute.


Definition and Usage

The onfocus attribute is triggered when an element gets focus.

Onfocus is commonly used with <input>, <select>, and <a> elements.

Tip: The opposite of the onfocus attribute is the onblur event.

Note: The onfocus attribute cannot be used with the following elements: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, or <title>.


Differences Between HTML 4.01 and HTML5

None.


Syntax

Attribute Values

Value Description
script Specifies the script to run when the onfocus event is triggered

❮ Att Keygen Form Att Fieldset Disabled ❯