Accesskey attribute in HTML5

In this article i am going to describe implementation of Accesskey attribute in HTML5.
  • 2111

Accesskey Attribute in HTML5

The accesskey attribute specifies a shortcut key to activate/focus an element. After creating shortcut key we can access element by using "shift +alt+ shortcut key name" .The accesskey attribute allows the user to activate a control on a page using a keyboard shortcut. This may save time for users who would otherwise need to tab through a series of form controls or move the mouse to get to the desired link.

The key combination that activates the link to which the accesskey is applied varies depending on the platform and browser combination. For IE/Windows, users press Alt + accesskey, while Firefox/Windows users press Alt + Shift + accesskey; users of most Mac browsers press Ctrl + accesskey; in Opera, pressing Shift + Esc displays a list of links for which accesskey attributes are defined, allowing users to choose the key they want to use.

Accesskey attribute is a global attribute in HTML. Global means it can be use on any HTML element.

Difference  between HTML5 and HTML4.01

In HTML5, the accesskey attribute can be used on any HTML element.

In HTML 4.01, the accesskey attribute can be used with: <a>, <area>, <button>, <input>, <label>, <legend>, and <textarea>.

Syntax

<element accesskey=" character">

Browser Support

Accesskey Attribute is supported in all major browsers.

Attribute Value

    Attribute     Description
   character specifies a shortcut key to activate/focus an element

Example of Attributekey in HTML5

<!DOCTYPE html> 

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">

<head>

    <meta charset="utf-8" />

    <title>Accesskey attribute in HTML5</title>

</head>

<body>

    <h1>Use of Accesskey Attribute in HTML5</h1>

    <a href="http://www.c-sharpcorner.com/html" accesskey="h">HTML tutorial</a><br>

    <a href="http://www.codekhan.com/css" accesskey="c">CSS tutorial</a>

    <p><b>press Shift+Alt+h for go C-sharpcorner.com and press Shift+Alt+c for go codekhan.com</b></p>

</body>

</html>

Output

accesskey.jpg

© 2019 DotNetHeaven. All rights reserved.