What is an HTML attribute

HTML attribute

1. An HTML attribute is an associated property of an HTML element and used to extend the capability of an HTML element.

2. HTML attributes (usually) have values and are written after a "=" after the name of the attribute.

3. Attribute value pair is placed before the last ">" of an HTML start tag.

html attribute

4. Any number of attribute value pairs (if they are applicable to that element) separated by space (white space) can be used with an element.

html attribute

5. In HTML 4.01, values of the attributes may be wrapped by double quotes, which is not mandatory. But in XHTML it is mandatory.

6. HTML attribute names are case sensitive.

7. Values of HTML attributes are not case-sensitive.

Pictorial presentation of using HTML attribute

html attribute

Example of using HTML attribute

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
 HTML a tag example - HTML tutorial | w3resource
 <a href="/index.php" accesskey="W" name="w3resource home">Visit w3resource.com to learn web development</a>
 <!--href,accesskey and name are attributes of HTML a element. /index.php, W and w3resource home are their respective values.-->


Visit w3resource.com to learn web development

These are the valid HTML 4.01 attributes

abbr ,accept-charset, accept, accesskey, action, align, alink, alt, archive, axis,background, bgcolor, border, cellpadding, char, charoff, charset, checked, cite, cite, class, classid, clear, code, codebase, codetype, color, cols colspan, compact, content, coords, coords, data, datetime, declare, defer, dir, dir, disabled, enctype, face, forframe, frameborder, headers, height, height, href, hreflang, hspace, http-equiv, id, ismap, label, label, lang, languagelink, longdesc, longdesc, marginheight, marginwidth, maxlength, media, method, multiple, name, nohref, noresize, noshade,nowrap, object, onblur, onchange, onclick, ondblclick, onfocus, onkeydown, onkeypress, onkeyup, onload, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, onreset, onselect, onsubmit, onunload, profile, prompt, readonly, readonly, rel, rev, rows, rows, rowspan, rules, schemescope, scrolling, selected, shape, shape, size, size, size, size, size, span, src, standby, start, style, summary, tabindex, target, text, title, type usemap, valign, value, valuetype, version, vlink, vspace, width.

Previous: List of HTML 4.01 elements
Next: HTML abbr attribute

Test your Programming skills with w3resource's quiz.

Follow us on Facebook and Twitter for latest update.