HOME

TheInfoList



OR:

HTML attributes are special words used inside the opening tag to control the element's behaviour. HTML attributes are a modifier of an ''
HTML element An HTML element is a type of HTML (HyperText Markup Language) document component, one of several types of HTML nodes (there are also text nodes, comment nodes and others). The first used version of HTML was written by Tim Berners-Lee in 1993 ...
type''. 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. 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.


Description

HTML attributes generally appear as
name–value pair A name–value pair, also called an attribute–value pair, key–value pair, or field–value pair, is a fundamental data representation in computing systems and applications. Designers often desire an open-ended data structure that allows for ...
s, separated by =, and are written within the start tag of an element, after the element's name: element content Where element names the HTML element type, and attribute is the name of the attribute, set to the provided value. The value may be enclosed in single or double quotes, although values consisting of certain characters can be left unquoted in HTML (but not XHTML). Leaving attribute values unquoted is considered unsafe. Although most attributes are provided as paired names and values, some affect the element simply by their presence in the start tag of the element (like the ismap attribute for the img element). The abbreviation element, abbr, can be used to demonstrate these various attributes: HTML This example displays as HTML in blue without being a link, and in most browsers, pointing the cursor at the abbreviation should display the title text "Hypertext Markup Language" within a floating yellow background (
tooltip The tooltip, also known as infotip or hint, is a common graphical user interface (GUI) element in which, when hovering over a screen element or component, a text box displays information about that element, such as a description of a button's f ...
).
Centered text
In this other example, your text will look like this:
Centered text
Most elements also take the language-related attributes lang and dir.


Common attributes

Usually,
HTML element An HTML element is a type of HTML (HyperText Markup Language) document component, one of several types of HTML nodes (there are also text nodes, comment nodes and others). The first used version of HTML was written by Tim Berners-Lee in 1993 ...
s can take any of several most common standard attributes ( See the complete list): * The id attribute provides a document-wide unique identifier for an element. This can be used as
CSS selector Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language such as HTML or XML (including XML dialects such as SVG, MathML or XHTML). CSS is a cornerstone technol ...
to provide presentational properties, by browsers to focus attention on the specific element, or by scripts to alter the contents or presentation of an element. Appended to the URL of the page, the URL directly targets the specific element within the document, typically a sub-section of the page. For example, the ID "Attributes" in http://en.wikipedia.org/wiki/HTML#Attributes (to refer to the section "Attributes" in the "HTML" page). * The class attribute provides a way of classifying similar elements. Multiple class names can be added by separating them with spaces. Semantically, for example, classes are used in
microformat Microformats (μF) are a set of defined HTML classes created to serve as consistent and descriptive metadata about an element, designating it as representing a certain type of data (such as contact information, geographic coordinates, events ...
s. Additionally authors of style sheets can construct selectors that match elements by class for styling purposes. For example, an HTML document might use the designation class="notation" to indicate that all elements with this class value are subordinate to the main text of the document. Such elements might be gathered together as footnotes on a page—instead of appearing in the place suggested by their position within the HTML source. The style sheet author might also define a rule with the .notation selector and define the property font-size: small;. * An author may use the style attribute to specify element-specific style rules. The style attribute can be used on any HTML element (it will validate on any HTML element; however, it is not necessarily useful). It is considered better practice to add the style information to a style sheet, often accomplished with selectors that match the element class or ID. Sometimes, however, inline styles are favored where style sheets are considered too cumbersome for a simple and specific or ad hoc style specification. * The title attribute is used to attach subtextual explanation to an element. In most browsers this attribute is displayed as what is often referred to as a
tooltip The tooltip, also known as infotip or hint, is a common graphical user interface (GUI) element in which, when hovering over a screen element or component, a text box displays information about that element, such as a description of a button's f ...
.


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. *Event attributes, added in HTML version 4, allow an element to specify
scripts Script may refer to: Writing systems * Script, a distinctive writing system, based on a repertoire of specific elements or symbols, or that repertoire * Script (styles of handwriting) ** Script typeface, a typeface with characteristics of handw ...
to be run under specific circumstances.


Required and optional


Used by one element

* : , * : * : , , , , * : , , , * : * : * : * : * : * : , * : * : , , * : , , , , * : * : * : * : , * : * : , , , , * :


Used by two elements

* and : ** coords — coordinates of an or a within it. ** shape — shape of an or a within it. Values: default, rect, circle, poly. * and : **
hreflang The rel="alternate" hreflang="x" link attribute is a HTML meta element described in RFC 8288. Hreflang specifies the language and optional geographic restrictions for a document. Hreflang is interpreted by search engines and can be used by webmast ...
— Language code of the linked document. (, ) ** rel — Nature of the linked document (relative to the page currently displayed). Free text for , but uses a set of terms (alternate, appendix, bookmark, chapter, contents, copyright, glossary, help, home, index, next, prev, section, start, stylesheet, subsection). ** rev — Nature of the currently displayed page (relative to the linked document). Varies for and as for rel. * and : ** archive — archive URL(s) (, ) ** codebase — base URL (, ) * and : ** color — text color ''(deprecated)'' (, ) ** face — font family ''(deprecated)'' (, ) * and : ** span — number of columns spanned (, ) * and : ** datetime — date and time of text or . * and : ** accept — types of files accepted when uploading or * and : ** frameborder — value (0 or 1) specifies whether to display a border around the or . ** marginheight — top and bottom margins in pixels around the or . ** scrolling — value (yes, no, auto) specifies whether to display scroll bars around the or . ** marginwidth — left and right margins in pixels around the or . * and : ** cols — number of visible columns in or ''(some variation)'' ** rows — number of visible rows in or ''(some variation)'' * and : ** usemap — specifies name of a map element to use with -or- URL of an image-map to use with . * and : ** readonly — specifies read-only text for and . * and : ** media — specifies display device for and . Values: all, aural, braille, handheld, print, projection, screen, tty, TV. * and : ** label — description text for an or . * and : ** abbr — abbreviated version of a table or . ** axis — category name for a table or . ** colspan — number of columns spanned by a table or . ** nowrap — ''(deprecated)'' prevents wrapping of a table or . ** rowspan — number of rows spanned by a table or . ** scope — no effect on normal browser display, but marks a table or as a logical header for other cells. Values: col, colgroup, row, rowgroup.


Used by multiple elements

* align — , , , , , , , , :*align also deprecated in , , to , , , , , , , *
alt Alt or ALT may refer to: Abbreviations for words * Alt account, an alternative online identity also known as a sock puppet account * Alternate character, in online gaming * Alternate route, type of highway designation * Alternating group, mathema ...
— , , , * bgcolor — , , , , * border — , , * char — , , , , , , , * charoff — , , , , , , , * charset — , , * cite — , , , * compact — , , , * disabled — , , , , , * height — , , , . Also deprecated in , * href — , , , * hspace — , . Also deprecated in * longdesc — , , * name — , , , , , , , , , , , , * size — , , , , * src — , , , , * target — , , , , * type — , , , , , , , , , * valign — , , , , , , , * value — , , , , * vspace — , , * width — , , , , , , , , , ,


Standard attributes

''Standard attributes'' are also known as ''global attributes'', and function with a large number of elements. 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. 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. The table below lists some common standard attributes, and some elements they can function with.


Event attributes

The standard attributes include the ''event handler attributes''. They are all prefixed on-: 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.
{, class="wikitable sortable" , - !Element !At !At !At !At !At !At !At !At !At !At !At !At !At !At !At !At !At , - ! , onload , onunload , , , , , , , , , , , , , , , , - ! , onload , onunload , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - !, , , , , , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , onabort , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , , , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , onblur , onfocus , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , onblur , onfocus , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , onblur , onfocus , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , onblur , onfocus , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , onblur , onfocus , , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , onblur , onfocus , onchange , , - ! , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , onblur , onfocus , onchange , onselect , - !{{MDNHTMLRef, textarea , , , , onclick , ondblclick , onmousedown , onmousemove , onmouseout , onmouseover , onmouseup , onkeydown , onkeypress , onkeyup , onblur , onfocus , onchange , onselect


See also

*
HTML element An HTML element is a type of HTML (HyperText Markup Language) document component, one of several types of HTML nodes (there are also text nodes, comment nodes and others). The first used version of HTML was written by Tim Berners-Lee in 1993 ...


References

HTML