FazBrowse Wikipedia Viewer | Main Page |
Search Wikipedia:
|
Viewing: https://en.wikipedia.org/wiki/HTML_attribute

HTML attribute

Contents
    Common attributes
Varieties
Required and optional
    Used by two elements
    Used by multiple elements

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 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.

Doctype HTML is a declaration that tells the browser what version of HTML the document is written in.

Some attribute types function differently when used to modify different element types. For example, the attribute name is used by several element types, but has slightly different functions in each.

<abbr id="anId" class="aClass" style="color:blue;" title="Hypertext Markup Language">HTML</abbr>

This example displays as HTML in blue without being a link, and in most browsers, pointing the cursor at the abbreviation should display the title text "Hypertext Markup Language" within a floating yellow background (tooltip).

Centered text</div>"}}'><div style="text-align: center;">Centered text</div>

In this other example, your text will look like this:

Centered text

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

Common attributes

edit

Usually, HTML elements can take any of several most common standard attributes (See the complete list):

Varieties

edit

HTML attributes are generally classified as required attributes, optional attributes, standard attributes, and event attributes:

Required and optional

edit

Used by two elements

edit
  • <a>, <link> 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 <applet> and <object>)
  • codebase — base URL (<basefont> and <font>)
  • face — font family (deprecated) (<col> and <colgroup>)
  • deletion or <input>:
  • <frameset> or <textarea> (some variation)
  • <img> -or- URL of an image-map to use with <textarea>:
  • <optgroup> or <th>:
  • Used by multiple elements

    edit