20.2. Tag vs. element Tags aren't the same thing as elements. Tags describe elements and delimit them. In Figure 20-1 the pet carrier, metaphorically speaking, is an element. The contents of the carrier is the content of an element. It is bounded by two tags. Figure 20-1. Tags aren't elements! The start-tag, at the left, describes the element. It contains three names: -
The element-type name (dog), which says what type of element it is. -
A unique identifier, or id (Spike), which says which particular element it is. -
The name of an attribute that describes some other property of the element: weight="8 lbs". The end-tag, at the right, marks the end of the element. It repeats the element-type name. When people talk about a tag name: -
They are referring to the element-type name (in this case, dog). -
They are making an error, because tags aren't named. And when they talk about an element name: -
They are again referring to the element-type name. -
They are again making an error, because an element is named by its unique identifier (in this case, Spike). |