World Library  
Flag as Inappropriate
Email this Article

HTML attribute

Article Id: WHEBN0026808274
Reproduction Date:

Title: HTML attribute  
Author: World Heritage Encyclopedia
Language: English
Subject: XHTML, Cascading Style Sheets, UF-audio-part, Aviation accidents and incidents, Infobox ballet company/doc
Collection:
Publisher: World Heritage Encyclopedia
Publication
Date:
 

HTML attribute

An HTML attribute is a modifier of an HTML element. HTML attributes generally appear as name-value pairs, separated by "=", and are written within the start tag of an element, after the element's name:

<tag attribute="value">(content to be modified by the tag)tag>
Where tag names the HTML element, 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).[1][2] Leaving attribute values unquoted is considered unsafe.[3]

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[4] (like the ismap attribute for the img element[5]).

Most elements can take any of several common attributes:

  • The id attribute provides a document-wide unique identifier for an element.[6] This can be used as CSS selector 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://articles/HTML#Attributes
  • The class attribute provides a way of classifying similar elements. This can be used for semantic or presentation purposes. Semantically, for example, classes are used in microformats. Presentationally, 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 and presented as footnotes on a page instead of appearing in the place where they occur in the HTML source.
  • An author may use the style non-attributal codes presentational properties to a particular element. It is considered better practice to use an element’s id or class attributes to select the element with a stylesheet, though sometimes this can be too cumbersome for a simple and specific or ad hoc application of styled properties.
  • 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 abbreviation element, abbr, can be used to demonstrate these various attributes:

HTML

This example displays as HTML; in most browsers, pointing the cursor at the abbreviation should display the title text "Hypertext Markup Language."

Most elements also take the language-related attributes lang and dir.

Varieties

HTML attributes are generally classed 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.[7] Event attributes, added in HTML version 4, allow an element to specify scripts to be run under specific circumstances.[8]

Required and optional HTML attributes

Used by one tag

  • : ,
  • :
  • : , , , ,
  • :
  • : , , ,
  • :
  • :
  • :
  • :
  • :
  • : ,
  • :
  • : , ,
  • : , , , ,
  • :
  • :
  • :
  • : ,
  • :
  • : , , , ,
  • :

Used by two tags

  • and :
    • coords — coordinates of an or a within it.
    • shape — shape of an or a within it. Values: default, rect, circle, poly.
  • and :
    • hreflang — 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 tag 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 tags

  • align — , , , , , , , ,
— also (deprecated) in , , to , , , , , , ,
  • alt — , , ,
  • bgcolor — , , , ,
  • border — , ,
  • char — , , , , , , ,
  • charoff — , , , , , , ,
  • charset — , ,
  • cite — , , ,
  • compact — , , ,
  • disabled — , , , , ,
  • height - , , , — also (deprecated) ,
  • href — , , ,
  • hspace — , — also (deprecated)
  • longdesc — , ,
  • name — , , , , , , , , , , , ,
  • size — , , , ,
  • src — , , , , )
  • target — , , , ,
  • type — , , , , , , , , ,
  • valign — , , , , , , ,
  • value — , , , ,
  • vspace — , ,
  • width — , , , , , , , , , ,

Standard attributes

id
dir lang xml:lang
dir lang xml:lang
dir lang xml:lang
dir lang xml:lang
title dir lang xml:lang
id class style title
id class style title
id class style title
id class style title
id class style title
id class style title dir lang
id class style title dir lang
id class style title dir lang
id class style title dir lang
id class style title dir lang
id class style title dir lang
id class style title dir lang
id class style title dir lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
, , , , , id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang
id class style title dir lang xml:lang accesskey
id class style title dir lang xml:lang accesskey
id class style title dir lang xml:lang tabindex
id class style title dir lang xml:lang tabindex
id class style title dir lang xml:lang accesskey tabindex
id class style title dir lang xml:lang accesskey tabindex
id class style title dir lang xml:lang accesskey tabindex
id class style title dir lang xml:lang accesskey tabindex
id class style title dir lang xml:lang accesskey tabindex

Event attributes

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
onclick ondblclick onmousedown onmousemove onmouseout onmouseover onmouseup onkeydown onkeypress onkeyup onblur onfocus onchange onselect

References

  1. ^ "On SGML and HTML". World Wide Web Consortium. Retrieved November 16, 2008. 
  2. ^ "XHTML 1.0 - Differences with HTML 4". World Wide Web Consortium. Retrieved November 16, 2008. 
  3. ^ Korpela, Jukka (July 6, 1998). "Why attribute values should always be quoted in HTML". Cs.tut.fi. Retrieved November 16, 2008. 
  4. ^ "Tags used in HTML". World Wide Web Consortium. November 3, 1992. Retrieved November 16, 2008. 
  5. ^ "Objects, Images, and Applets in HTML documents". World Wide Web Consortium. December 24, 1999. Retrieved November 16, 2008. 
  6. ^ However, multiple identifiers may apply to the same element; in particular an element may be inside another element, each having an identifier.
  7. ^ "HTML / XHTML Standard Attributes". w3schools.com. 
  8. ^ "HTML / XHTML Standard Event Attributes". w3schools.com. 
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and USA.gov, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for USA.gov and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
 
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
 
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.
 


Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.