Content deleted Content added
Undid revision 1135375382 by Misbah6666 (talk) revert addition of unsourced section; seemingly arbitrary selection of an attribute to write about; not an WP:RS |
Fix grammar |
||
Line 2:
{{Html series}}
'''HTML attributes''' are special words used inside the opening tag to control the element's behaviour. HTML attributes are a modifier of
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 36:
* The '''<code>id</code>''' attribute provides a document-wide unique identifier for an element.<ref>However, multiple identifiers may apply to the same element; in particular an element may be inside another element, each having an identifier.</ref><ref>{{Cite web|url=https://www.w3schools.com/html/html_id.asp|title=HTML id|website=www.w3schools.com|access-date=2020-04-27}}</ref><ref>{{Cite web|url=https://www.w3schools.com/tags/att_global_id.asp|title=HTML Global id Attribute|website=www.w3schools.com|access-date=2020-04-27}}</ref> 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 <code><nowiki>http://en.wikipedia.org/wiki/HTML#Attributes</nowiki></code> (to refer to the section "Attributes" in the "HTML" page).
* The '''<code>class</code>''' attribute provides a way of classifying similar elements. Multiple class names can be added by separating them with spaces.<ref>{{Cite web|url=https://www.w3schools.com/html/html_classes.asp|title=HTML Classes|website=www.w3schools.com|access-date=2020-04-27}}</ref><ref>{{Cite web|url=https://www.w3schools.com/tags/att_global_class.asp|title=HTML Global class Attribute|website=www.w3schools.com|access-date=2020-04-27}}</ref> Semantically, for example, classes are used in [[microformat]]s. Additionally authors of style sheets can construct [[CSS selector|selectors]] that match elements by class for styling purposes. For example,
* An author may use the '''<code>style</code>''' attribute to specify element-specific style rules. The '''<code>style</code>''' 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 (web development)|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 '''<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]].
|