When referring to HTML, it is useful to know some words that are used to refer to the
tags and the parts of the tags.
Tags is the word used to refer to everything within the two angle
brackets. For example, in the BODY tag, the start tag is:
And the end tag is:
Similarly, for the IMG tag:
<IMG SRC="myPicutre.gif" ALT="My picture">
Everything within the angle brackets is called the tag, in HTML talk.
Some tags must have beginning and end tags.
For example, the <BODY> tag must have an end tag (</BODY>).
Some tags may have beginning and end tags.
For example, the paragraph tag <P> may have an end tag </P> or not.
And other tags, such as the <IMG> tag, do not
have end tags. They are called empty tags, and are written like
this in XHTML:
<img src="myPage.htm" />
We often refer to HTML tags by using the tag name,
as I have done. Similarly, the IMG tag is referred to by its tag name (IMG). We can also
refer to the A element in A tags when we distinguish it from the attributes (although we
can also refer to anything in the tags as an element, or even to the tags themselves as
elements when we think of them as being part of the document).
An attribute is a named
value. So in A tags, the HREF element :-) is referred to as an attribute
of the A tag. The HREF attribute normally takes an URL as a value. In:
<IMG SRC="myPicture.gif" ALT="My Picture"
The ALT attribute has the value "My Picture", And the BORDER attribute takes
the value zero.
So, every HTML tag has a tag name, and zero or more attributes with values. For
<A HREF="#" onClick="MyFunction()"> .... </A>
contains the attribute, "onClick", with the value
has no attributes.
Some sneaky attributes operate under different names. So in the previous example, onClick
is a method and it is also an event handler. Nonetheless, it is still an
attribute. onClick is an event handler because it handles the mouse click
event on its A tag. So when the user clicks on the A tag, the onClick
event handler does something (a method) according to the instructions given by the
Clearly, we can communicate better when we use an agreed language. The HTML tags
are angle brackets and their contents. The first element in the HTML tag is the tag
name. The other elements or attributes can be placed in any
order inside the tags.
The attributes may also be described using other words - for example, onClick can be
described as a method or an event handler.