Content deleted Content added
Tags: Reverted Mobile edit Mobile web edit |
m →top: +link |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 1:
{{short description|Special words used inside the opening tag to control the element's behaviour}}
'''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 tags|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.
Line 16:
Where <code>element</code> names the HTML element type, and <code>attribute</code> is the name of the attribute, set to the provided <code>value</code>. 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).<ref>{{cite web|url=http://www.w3.org/TR/html401/intro/sgmltut.html#h-3.2.2 |title=On SGML and HTML |publisher=World Wide Web Consortium |access-date=November 16, 2008}}</ref><ref>{{cite web|url=http://www.w3.org/TR/xhtml1/diffs.html#h-4.4|title=XHTML 1.0 – Differences with HTML 4|publisher=World Wide Web Consortium|access-date=November 16, 2008}}</ref> Leaving attribute values unquoted is considered unsafe.<ref>{{cite web|first=Jukka|last=Korpela|url=https://jkorpela.fi/qattr.html|title=Why attribute values should always be quoted in HTML|publisher=Cs.tut.fi |date=July 6, 1998|access-date=November 16, 2008}}</ref>
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<ref name="tagshtml
The abbreviation element, <code>abbr</code>, can be used to demonstrate these various attributes:
|