Skip to main content

Rule Three - All XML attributes must have quotes around them

We talked about attributes a little earlier. 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.

Even if the value of an attribute is a number, it still has to have quotes around it in order to be valid XHTML markup.

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

Here's another example showing attributes in action with the <img /> element:

<img src="SallySmile.jpg"

width="100" height="220"

alt="photo of Sally Smith smiling toward the camera" />

There are four attributes:
src with a value of "SallySmile.jpg"
width with a value of "100"

height with a value of "220"

alt with a value of "photo of Sally Smith smiling toward the camera"

Notice how each attribute includes an equal sign "=" and the value is surrounded by quotes.