- The first line of every XHTML5 document 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 XHTML5 DTD for the
<!doctype> tag.
<!DOCTYPE html>
- 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 XHTML5 file, between the <head> and </head> tags, place a <meta> tag as shown below:
<meta charset="utf-8" />
- 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