Top Qs
Timeline
Chat
Perspective

HTML attribute

Special words used inside the opening tag to control the element's behaviour From Wikipedia, the free encyclopedia

Remove ads

HTML attributes are special words used to adjust the behavior or display of an HTML element. An attribute either modifies the default functionality of an element type or provides functionality to certain element types unable to function correctly without them. In HTML syntax, an attribute is added to an HTML start tag.

Several basic attributes types have been recognized, including: (1) required attributes needed by a particular element type for that element type to function correctly; (2) optional attributes used to modify the default functionality of an element type; (3) standard attributes supported by many element types; and (4) event attributes used to cause element types to specify scripts to be run under specific circumstances.

Doctype HTML is a declaration that tells the browser what version of HTML the document is written in.

Some attribute types function differently when used to modify different element types. For example, the attribute name is used by several element types, but has slightly different functions in each.[1]

  • element
Remove ads

Varieties

HTML attributes are generally classified as required attributes, optional attributes, standard attributes, and event attributes:

  • Usually the required and optional attributes modify specific HTML elements
  • While the standard attributes can be applied to most HTML elements.[2]
  • Event attributes, added in HTML version 4, allow an element to specify scripts to be run under specific circumstances.[3]

Required and optional

Used by multiple elements

Remove ads

Standard attributes

Summarize
Perspective

Standard attributes are also known as global attributes, and function with a large number of elements.[4] They include the basic standard attributes: these include accesskey, class, contenteditable, contextmenu, data, dir, hidden, id, lang, style, tabindex, title. There are also some experimental ones. Both xml:lang and xml:base have been deprecated. The multiple aria-* attributes improve accessibility.[4] The event handler attributes are listed later on.

Technically all standard attributes must be accepted by all elements, though they will not function with some elements.[5] The table below lists some common standard attributes, and some elements they can function with.

Remove ads

Event attributes

Summarize
Perspective

The standard attributes include the event handler attributes. They are all prefixed on-:[4]

  • onabort
  • onautocomplete
  • onautocompleteerror
  • onblur
  • oncancel
  • oncanplay
  • oncanplaythrough
  • onchange
  • onclick
  • onclose
  • oncontextmenu
  • oncuechange
  • ondblclick
  • ondrag
  • ondragend
  • ondragenter
  • ondragexit
  • ondragleave
  • ondragover
  • ondragstart
  • ondrop
  • ondurationchange
  • onemptied
  • onended
  • onerror
  • onfocus
  • oninput
  • oninvalid
  • onkeydown
  • onkeypress
  • onkeyup
  • onload
  • onloadeddata
  • onloadedmetadata
  • onloadstart
  • onmousedown
  • onmouseenter
  • onmouseleave
  • onmousemove
  • onmouseout
  • onmouseover
  • onmouseup
  • onmousewheel
  • onpause
  • onplay
  • onplaying
  • onprogress
  • onratechange
  • onreset
  • onresize
  • onscroll
  • onseeked
  • onseeking
  • onselect
  • onshow
  • onsort
  • onstalled
  • onsubmit
  • onsuspend
  • ontimeupdate
  • ontoggle
  • onvolumechange
  • onwaiting

Event attributes, added in HTML version 4, allow an element to specify scripts to be run under specific circumstances. The table below lists some common event handler attributes, and some elements they can function with.

More information Element, onload ...
Remove ads

See also

References

Loading related searches...

Wikiwand - on

Seamless Wikipedia browsing. On steroids.

Remove ads