HTML elements consist of a tag name and a set of name/value
pairs known as attributes. The
<a> element that defines a hyperlink,
for example, uses the value of its
href attribute as the destination of the
link. The attribute values of HTML elements are available as
properties of the HTMLElement objects that represent those elements.
The DOM also defines other APIs for getting and setting the values of
XML attributes and nonstandard HTML attributes. The subsections that
follow have details.
The HTMLElement objects that represent the elements of an HTML
document define read/write properties that mirror the HTML
attributes of the elements. HTMLElement defines properties for the
universal HTTP attributes such as
dir, and event handler properties like
subtypes define attributes specific to those elements. To query the
URL of an image, for example, you can use the
src property of the HTMLElement that
// The src attribute is the URL of the image
// Since we looked up the image by id
Similarly, you might set the form-submission attributes of a
<form> element with code
// First <form> in the document
// Set URL to submit it to.
// HTTP request type
HTML attributes are not ...