Home » Articole » News » HTML attributes

HTML attributes

posted in: News 0

htmlAttributes are used to specify the properties of HTML elements. There are 188 attributes in the HTML version 4.

Some attributes apply to almost all elements:

  • id (unique identifier) and class (repeatable identifier) generic attributes to enable the application of external treatments such as applying styles of presentation or manipulation of the document tree via a scripting language. It adds the style attribute to define the presentation style of the item (usually CSS), and title attribute providing additional information usually free (The major exception is the use of title attribute to determine the permanent style and possible alternative styles applied to a document elements via link).
  • dir and lang internationalization attributes specifying the direction of writing and language of the content;
  • onclick, ondblclick, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, and onmouseup event handlers, which capture events generated in the element to call a script.

Other attributes are specific to a single element, or the like. For example:

  • the elements needed to include in the graphic resources have attributes of height and width, so that the browser can anticipate the size of the resource to be displayed until it has been downloaded: img, object, iframe.
  • specific elements feature an attribute assuming a single function, such as the label element for tags of form controls and its attribute for designating the concerned control: it is, in HTML, and with the attributes of usemap and ismap for images, one of the few explicit and formalized associations between elements, regardless of their linear order in the source code.

Most attributes are optional. However, some elements have mandatory attributes:

  • in nature: the img element is mandatory with a src attribute specifying the URI of the graph resource that it represents. It is the same for all so-called “empty” and “replaced” elements which, at the cost of a departure from SGML rules, do not have their own content. This is also the case of non-empty elements for functional reasons, such as the form element whose action attribute tells the target server that will process the data after submission;
  • for reasons related to the accessibility of content: images are well equipped with a mandatory alt attribute to indicate a raw textual content to replace the graphics resource in consultation contexts where it can not be returned or perceived.

The content type HTML attributes partly escapes the scope of this standard, and validation reports third-standards such as URIs, content types or codes of languages.

Some attributes are finally Boolean. These are the only attributes whose syntax may be validly implied in HTML: the selected attribute of a form control can be shortened as selected replacing the full form selected=”selected”. This particular form is one of the points differentiating HTML from the syntax of “well-formed” document as XML.

Translated from Wikipedia

Leave a Reply

Your email address will not be published. Required fields are marked *