To be compatible with XHTML (and XML in general), the ampersand must be escaped. To do so requires the use of an SGML/XML entity.
There are three different entities that can be used to represent the ampersand:
Named entity: &
(This is one of the five predefined entities defined in the XML specification.)
Decimal numeric character reference: &
Hexadecimal numeric character reference: &
So, the value of your example href
attribute could be represented in one of these three ways:
href="index.php?c=tutorials&p=cat&cid=1"
href="index.php?c=tutorials&p=cat&cid=1"
href="index.php?c=tutorials&p=cat&cid=1"
Of course, it would be valid to mix the above entities like this:
href="index.php?c=tutorials&p=cat&cid=1"
^^^^^ ^^^^^
...but most would argue for taking a consistent approach throughout a document (and even an entire web site).
Of the three entities that can be used to represent the ampersand, I believe that &
is used most commonly in XHTML.
Final note: One of the above entities should also be used when authoring HTML, however browsers today do not require that the ampersand be escaped.