Well formedness rules | Example |
---|---|
1. all elements must have a closing tag |
<p>text</p> <hr /> |
2. all elements must be properly nested | <b>bold text <i>bold italic text</i></b> |
3. single root (document) element allowed |
<html> <head> ... </head> <body> ... </body> </html> |
4. tag and attribute names are case sensitive |
<size>320 ml</size> <Size>extra large</Size> <SIZE>relative</SIZE> |
5.1 attributes can only go in the start tag and must be of the form name="value" and value is quoted | <car colour='silver trim'> |
5.2 attribute names must be unique in the tag | <garment usSize="6" ukSize="10"> |
XML declaration | |
first thing in the document - indicates version of xml and optional encoding | <?xml version="1.0" encoding="UTF-8"?> |
Processing Instructions | |
asks the processing application to do something | <?xml-stylesheet href="mystyle.css" type="text/css" ?> |
Comments | |
Same as HTML | <!-- comment --> |
Character references and Entities | |
Character refs allow any character to be inserted | Φ |
Entities allow special symbols and predefined text to be entered | < ©w; |
CDATA sections | |
For including text not to be treated as XML | <![CDATA[ <wrong attr=val />]]> |