Free since 2005 · No login required
AT

Academic Tutorials

Learn at your own pace

site-mobile-top-banner · 320x50

Attributes and XML

Added 26 Jul 2008

If you've written HTML, you've almost certainly used  attibutes without even realizing it. For example, the image tag requires the use of at least one attribute, the src attribute in order to display any images. But with HTML, if you include an attribute that is incorrect or invalid, the browsers will ignore it.

In XML, like HTML, an attribute is a part of an element that provides additional information about that element. You might think of an attribute as an adjective describing the element it is within. For example, if you have an element "dog", it might have an attribute color="white":

Attributes are formed in name=value pairs. Thus, in XML, you would never write - that would be incorrect. One way to think about it is to think of the most generic instance of the adjective you are using. If you're describing your "dog" element as "big", "white", and "smart", then you should probably have three attributes: size, color, and intelligence. Then you could have one and another element