HTML attribute: Difference between revisions

Content deleted Content added
Mike Serfas (talk | contribs)
Event attributes table
SmackBot (talk | contribs)
m Add uncategrized tag and general fixes., added orphan tag
Line 1:
{{Orphan|date=April 2010}}
 
'''''HTML attributes''''' are modifiers of [[HTML elements]]. They generally appear as name-value pairs, separated by "=", and are written within the start tag of an element, after the element's name:
:<nowiki><''tag'' ''attribute''="''value''">(content to be modified by the tag)</tag></nowiki>
Line 9 ⟶ 11:
Most elements can take any of several common attributes:
 
* The <code>id</code> attribute provides a document-wide unique identifier for an element. This can be used by stylesheets 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, it provides a globally-unique identifier for an element; typically a sub-section of the page. For example, the ID "Attributes" in <code><nowiki>http://en.wikipedia.org/wiki/HTML#Attributes</nowiki></code>
* The <code>class</code> attribute provides a way of classifying similar elements. This can be used for [[semantics|semantic]] or presentation purposes. Semantically, for example, classes are used in [[microformat]]s. Presentationally, for example, an HTML document might use the designation <code>class="notation"</code> 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 <code>style</code> non-attributal codes presentational properties to a particular element. It is considered better practice to use an element’s <code>id</code> or <code>class</code> 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 <code>title</code> 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, <code>abbr</code>, can be used to demonstrate these various attributes:
Line 25 ⟶ 27:
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.<ref>{{cite web|url=http://www.w3schools.com/tags/ref_standardattributes.asp|title=HTML / XHTML Standard Attributes|publisher=w3schools.com}}</ref> Event attributes, added in HTML version 4, allow an element to specify scripts to be run under specific circumstances.<ref>{{cite web|url=http://www.w3schools.com/tags/ref_eventattributes.asp|title=HTML / XHTML Standard Event Attributes|publisher=w3schools.com}}</ref>
 
=== Required and optional HTML attributes ===
====Used by one tag====
* {{w3schools|applet}}: {{w3schools|applet|code}}, {{w3schools|applet|object}}
Line 93 ⟶ 95:
** scope — no effect on normal browser display, but marks a table {{w3schools|td|scope|t=cell}} or {{w3schools|td|scope|t=header}} as a logical header for other cells. Values: col, colgroup, row, rowgroup.
 
==== Used by multiple tags ====
* <b>'''align</b>''' — {{w3schools|applet|align|v=1}}, {{w3schools|col|align|v=1}}, {{w3schools|colgroup|align|v=1}}, {{w3schools|object|align|v=1}}, {{w3schools|tbody|align|v=1}}, {{w3schools|td|align|v=1}}, {{w3schools|tfoot|align|v=1}}, {{w3schools|th|align|v=1}}, {{w3schools|thead|align|v=1}}
::— also (deprecated) in {{w3schools|caption|align|v=1}}, {{w3schools|div|align|v=1}}, {{w3schools|h1|align|v=1}} to {{w3schools|h6|align|v=1}}, {{w3schools|hr|align|v=1}}, {{w3schools|iframe|align|v=1}}, {{w3schools|img|align|v=1}}, {{w3schools|input|align|v=1}}, {{w3schools|legend|align|v=1}}, {{w3schools|p|align|v=1}}, {{w3schools|table|align|v=1}}
* <b>'''alt</b>''' — {{w3schools|applet|alt|v=1}}, {{w3schools|area|alt|v=1}}, {{w3schools|img|alt|v=1}}, {{w3schools|input|alt|v=1}}
* <b>'''bgcolor</b>''' — {{w3schools|body|bgcolor|v=1}}, {{w3schools|table|bgcolor|v=1}}, {{w3schools|td|bgcolor|v=1}}, {{w3schools|th|bgcolor|v=1}}, {{w3schools|bgcolor|tr|v=1}}
* <b>'''border</b>''' — {{w3schools|img|border|v=1}}, {{w3schools|object|border|v=1}}, {{w3schools|table|border|v=1}}
* <b>'''char</b>''' — {{w3schools|char|col|v=1}}, {{w3schools|colgroup|v=1}}, {{w3schools|tbody|v=1}}, {{w3schools|td|v=1}}, {{w3schools|tfoot|v=1}}, {{w3schools|th|v=1}}, {{w3schools|thead|v=1}}, {{w3schools|tr|v=1}}
* <b>'''charoff</b>''' — {{w3schools|col|charoff|v=1}}, {{w3schools|colgroup|charoff|v=1}}, {{w3schools|tbody|charoff|v=1}}, {{w3schools|td|charoff|v=1}}, {{w3schools|tfoot|charoff|v=1}}, {{w3schools|th|charoff|v=1}}, {{w3schools|thead|charoff|v=1}}, {{w3schools|tr|charoff|v=1}}
* <b>'''charset</b>''' — {{w3schools|a|charset|v=1}}, {{w3schools|link|charset|v=1}}, {{w3schools|script|charset|v=1}}
* <b>'''cite</b>''' — {{w3schools|blockquote|cite|v=1}}, {{w3schools|del|cite|v=1}}, {{w3schools|ins|cite|v=1}}, {{w3schools|q|cite|v=1}}
* <b>'''compact</b>''' — {{w3schools|dir|compact|v=1}}, {{w3schools|menu|compact|v=1}}, {{w3schools|ol|compact|v=1}}, {{w3schools|ul|compact|v=1}}
* <b>'''disabled</b>''' — {{w3schools|button|disabled|v=1}}, {{w3schools|input|disabled|v=1}}, {{w3schools|optgroup|disabled|v=1}}, {{w3schools|option|disabled|v=1}}, {{w3schools|select|disabled|v=1}}, {{w3schools|textarea|disabled|v=1}}
* <b>'''height</b>''' - {{w3schools|applet|height|v=1}}, {{w3schools|iframe|height|v=1}}, {{w3schools|img|height|v=1}}, {{w3schools|object|height|v=1}} — also (deprecated) {{w3schools|td|height|v=1}}, {{w3schools|th|height|v=1}}
* <b>'''href</b>''' — {{w3schools|a|href|v=1}}, {{w3schools|area|href|v=1}}, {{w3schools|base|href|v=1}}, {{w3schools|link|href|v=1}}
* <b>'''hspace</b>''' — {{w3schools|applet|hspace|v=1}}, {{w3schools|object|hspace|v=1}} — also (deprecated) {{w3schools|img|hspace|v=1}}
* <b>'''longdesc</b>''' — {{w3schools|frame|longdesc|v=1}}, {{w3schools|iframe|longdesc|v=1}}, {{w3schools|img|longdesc|v=1}}
* <b>'''name</b>''' — {{w3schools|a|name|v=1}}, {{w3schools|applet|name|v=1}}, {{w3schools|button|name|v=1}}, {{w3schools|form|name|v=1}}, {{w3schools|frame|name|v=1}}, {{w3schools|iframe|name|v=1}}, {{w3schools|input|name|v=1}}, {{w3schools|map|name|v=1}}, {{w3schools|meta|name|v=1}}, {{w3schools|object|name|v=1}}, {{w3schools|param|name|v=1}}, {{w3schools|select|name|v=1}}, {{w3schools|textarea|name|v=1}}
* <b>'''size</b>''' — {{w3schools|basefont|size|v=1}}, {{w3schools|font|size|v=1}}, {{w3schools|hr|size|v=1}}, {{w3schools|input|size|v=1}}, {{w3schools|select|size|v=1}}
* <b>'''src</b>''' — {{w3schools|frame|src|v=1}}, {{w3schools|iframe|src|v=1}}, {{w3schools|img|src|v=1}}, {{w3schools|input|src|v=1}}, {{w3schools|script|src|v=1}})
* <b>'''target</b>''' — {{w3schools|a||targetv=1}}, {{w3schools|area|target|v=1}}, {{w3schools|base|target|v=1}}, {{w3schools|form|target|v=1}}, {{w3schools|link|target|v=1}}
* <b>'''type</b>''' — {{w3schools|button|type|v=1}}, {{w3schools|input|type|v=1}}, {{w3schools|li|type|v=1}}, {{w3schools|link|type|v=1}}, {{w3schools|object|type|v=1}}, {{w3schools|ol|type|v=1}}, {{w3schools|param|type|v=1}}, {{w3schools|script|type|v=1}}, {{w3schools|style|type|v=1}}, {{w3schools|ul|type}}
* <b>'''valign</b>''' — {{w3schools|col|valign|v=1}}, {{w3schools|colgroup|valign|v=1}}, {{w3schools|tbody|valign|v=1}}, {{w3schools|td|valign|v=1}}, {{w3schools|tfoot|valign|v=1}}, {{w3schools|th|valign|v=1}}, {{w3schools|thead|valign|v=1}}, {{w3schools|tr|valign|v=1}}
* <b>'''value</b>''' — {{w3schools|button|value|v=1}}, {{w3schools|input|value|v=1}}, {{w3schools|li|value|v=1}}, {{w3schools|option|value|v=1}}, {{w3schools|param|value|v=1}}
* <b>'''vspace</b>''' — {{w3schools|applet|vspace|v=1}}, {{w3schools|img|vspace|v=1}}, {{w3schools|object|vspace|v=1}}
* <b>'''width</b>''' — {{w3schools|applet|width|v=1}}, {{w3schools|col|width|v=1}}, {{w3schools|colgroup|width|v=1}}, {{w3schools|hr|width|v=1}}, {{w3schools|iframe|width|v=1}}, {{w3schools|img|width|v=1}}, {{w3schools|object|width|v=1}}, {{w3schools|pre|width|v=1}}, {{w3schools|table|width|v=1}}, {{w3schools|td|width|v=1}}, {{w3schools|th|width|v=1}}
 
==Standard attributes==
Line 1,023 ⟶ 1,025:
|tabindex
|}
 
===Event attributes===
{| class="wikitable" style="font-size:80%;"
Line 2,359 ⟶ 2,362:
==References==
<references />
 
{{Uncategorized|date=April 2010}}