- The first line of every XHTML document (when it loads in the browser) should always be the following XML declaration:
<?xml version="1.0" encoding="UTF-8" ?>
- No white space (i.e.: No spaces, No line breaks) before this tag.
- You include this XML element for validation -- The encoding is for accessibility
- HOWEVER - The PHP declaration also starts with <?, so to be able to do this in PHP, you must have the following as the first thing written out to the browser - only on PHPs that contain XHTML (not on pass-through pages)
- echo("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
- The second line of each document should use the XHTML Strict DTD for the
<!doctype> tag.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- The next line of code should be the opening <html> tag. The <html> tag in every document should always be:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- xmlns specifies the XML namespace for a document.
- xml:lang specifies the contents and attributes as English and is a required accessibility standard.
- lang specifies the content of a tag as English and is a required accessibility standard.
- At the top of every XHTML file, between the <head> and </head> tags, place a <meta> tag as shown below:
<meta http-equiv="Content-Type" content="text/html; UTF-8" />
- Without this line of code, you will receive an accessibility warning.
- The encoding type (UTF-8) should match the encoding in the XML declaration above.
- All pages should conform to the
wellformedness constraints of XML (and XHTML).
- All formatting should be done using CSS