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:
Required and optional
Used by multiple elements
- alt — <applet>, <area>, <img>, <input>
- bgcolor — <body>, <table>, <td>, <th>, <bgcolor>
- border — <img>, <object>, <table>
- char — <char>, <colgroup>, <tbody>, <td>, <tfoot>, <th>, <thead>, <tr>
- charoff — <col>, <colgroup>, <tbody>, <td>, <tfoot>, <th>, <thead>, <tr>
- charset — <a>, <link>, <script>
- cite — <blockquote>, <del>, <ins>, <q>
- compact — <dir>, <menu>, <ol>, <ul>
- disabled — <button>, <input>, <optgroup>, <option>, <select>, <textarea>
- height — <applet>, <iframe>, <img>, <object> . Also deprecated in <td>, <th>
- href — <a>, <area>, <base>, <link>
- hspace — <applet>, <object>. Also deprecated in <img>
- longdesc — <frame>, <iframe>, <img>
- name — <a>, <applet>, <button>, <form>, <frame>, <iframe>, <input>, <map>, <meta>, <object>, <param>, <select>, <textarea>
- size — <basefont>, <font>, <hr>, <input>, <select>
- src — <frame>, <iframe>, <img>, <input>, <script>
- target — <a>, <area>, <base>, <form>, <link>
- type — <button>, <input>, <li>, <link>, <object>, <ol>, <param>, <script>, <style>, <ul>
- valign — <col>, <colgroup>, <tbody>, <td>, <tfoot>, <th>, <thead>, <tr>
- value — <button>, <input>, <li>, <option>, <param>
- vspace — <applet>, <img>, <object>
- width — <applet>, <col>, <colgroup>, <hr>, <iframe>, <img>, <object>, <pre>, <table>, <td>, <th>
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.
Remove ads
See also
References
Wikiwand - on
Seamless Wikipedia browsing. On steroids.
Remove ads