Skip to main content

Some Terms: element, tag, and attribute

XHTML means you will be writing more precise markup code. And, to explain how XTML works we need more precise terms.

Here's a quick summary of what's what in web page markup.

markup of a paragraph element containing a strong element and a horizontal rule

An element is the start and stop tag and all the content between these two tags.

In the illustration there are three elements: p strong and hr

A tag is the start and stop marker for each element. Each tag is designated by the less than "<" and the greater than ">" signs. In the illustration there are five tags: <p> <strong> </strong> <hr /> and </p>.

An attribute is a descriptor that can be added onto a tag. You can think of attributes as adjectives. They help the browser describe the element in a little more detail.

There are two attributes in this example. id="intro" and class="narrow".

Every attribute consists of an identifier and a value. The value must be contained inside of quotation marks (either double or single as long as they match). For example, id and class are the identifiers and "intro" and "narrow".