XML - Attribute

About

Attribute in XML represents the (tree) attributes of an HTML element (node in the tree)

Ie they are used to associate name-value pairs with elements and are defined in a start tag of an empty tag.

The Name-Value pairs are referred to as the attribute specifications of the element.

In HTML, they are characteristics or descriptions for the content in the element.

Example

<termdef id="dt-dog" term="dog">

This Xml start tag defines:

  • for the attribute name “id” the attribute value “dt-dog”
  • for the attribute name “term” the attribute value “dog”

HTML Specification: The attribute value can remain unquoted if it doesn't contain space characters or any of “ ' ` = < or >. Otherwise, it has to be quoted using either single or double quotes. The value, along with the ”=“ character, can be omitted altogether if the value is the empty string.

<!-- empty attributes -->
<input name=address disabled>
<input name=address disabled="">

<!-- attributes with a value -->
<input name=address maxlength=200>
<input name=address maxlength='200'>
<input name=address maxlength="200">

List

All the attributes of an element are called the attribute list.

The list of supported attribute for an element can be defined in the attribute-list declaration

Declaration

An Attribute-list declaration is a declaration that specify the list of possible attribute for an element.

See attribute-list declaration for an example.

Documentation / Reference


Powered by ComboStrap