XML - Attribute

> Markup Language (ML) > Extensible Markup Language (XML)

1 - About

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


3 - 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">

4 - List

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

5 - Declaration

Attribute-list declarations specify the name, data type, and default value (if any) of each attribute associated with a given element type.


<?xml version="1.0" encoding="UTF-8"?>
        <!ELEMENT TABLE (ROW)*>
        <!ELEMENT ROW (#PCDATA)>
    <ROW COL1="25874" COL2="000005" />
    <ROW COL1="26084" COL2="000006" />

6 - Documentation / Reference

markup/xml/attribute.txt · Last modified: 2017/01/20 18:12 by gerardnico