How To Write Element Attributes Properly

Q

How To Write Element Attributes Properly? - XHTML Tutorials - Introduction To Tag and Attribute Syntax

✍: FYIcenter.com

A

If an attribute is allowed for an XHTML element, you must write the attribute inside the opening tag of this element. Here are some rules on writing element attributes:

  • An attribute must have a name and a value, separated by the equal sign "=".
  • An attribute name must be written in lower case letter.
  • An attribute value must be enclosed in a pair of quotes.
  • Multiple attributes can be written in any order.
  • Some attributes must use predefined values.

Here are some good examples of element attributes:

  • <td colspan="2"> - One attributes: "colspan".
  • <input type="text" name="Phone"> - Two attributes: "type" and "name".
  • <link rel="stylesheet" type="text/css" href="/_local.css"/> - Three attributes: "rel", "type" and "href".

2007-05-12, 5513👍, 0💬