HTML and XHTML
HTML is a computer language devised to allow website creation. These websites can then be viewed by anyone else connected to the Internet. It is relatively easy to learn, with the basics being accessible to most people in one sitting; and quite powerful in what it allows you to create. It is constantly undergoing revision and evolution to meet the demands and requirements of the growing Internet audience under the direction of the W3C (World Wide Web Consortium), the organisation charged with designing and maintaining the language and original creators of the internet.
A XHTML document is a document that has to be well-formed according to the rules of XML. Every tag has be closed and correctly nested, and for tags like img, input, link etc, a quick close tag should be added at the end of the tag, like this: <p>Content goes here</p>.
According to HTML standards, each HTML document requires a document type declaration. The "DOCTYPE" begins the HTML document and tells a validator which version of HTML to use in checking the document's syntax.
If standard HTML does not meet your needs but you still wish to gain the benefits of HTML validation you can introduce PHP by using the doctype in the PHP section below.
The following DOCTYPEs are commonly used:
- <!DOCTYPE HTML PUBLIC "–//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
-
This declares the document to be HTML 4.01 Strict.
- <!DOCTYPE HTML PUBLIC "–//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-
This declares the document to be HTML 4.01 Transitional.
- <!DOCTYPE HTML PUBLIC "–//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
-
This declares the document to be HTML 4.01 Frameset.
- <!DOCTYPE html PUBLIC "–//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1–strict.dtd">
-
This declares the document to be XHTML 1.0 Strict.
- <!DOCTYPE html PUBLIC "–//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1–transitional.dtd">
-
This declares the document to be XHTML 1.0 Transitional.
- <!DOCTYPE html PUBLIC "–//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1–frameset.dtd">
-
This declares the document to be XHTML 1.0 Frameset.
- <!DOCTYPE html PUBLIC "–//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-
This declares the document to be XHTML 1.1.
If you are building a large website I find that PHP can help greatly. With PHP it allows you to bring in files from a folder so for instance say you have a 25 page website and you spot an error on the navigation link, normally with a XHTML and HTML standard website you would have to open up all 25 files seperatly to edit the error, with PHP you can set a line of code called an include ( <?php include("includes/navigation.php"); ?> ) in the area where you want the navigation and call in your external navigation file, one edit of that file and the whole site has been updated. We will cover this further later.
- <?php
if(stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml")){
header("Content–Type: application/xhtml+xml; charset=UTF–8");
echo(´<!DOCTYPE html PUBLIC "–//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">´);
} else {
header("Content–Type: text/html; charset=UTF–8");
echo (´<!DOCTYPE html PUBLIC "–//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1–strict.dtd">´);
}
?> -
This declares the document to be XHTML 1.1. Which is displayed by Standard complient browsers.
If no complient browser is found it then declares the document to be XHTML 1.0 Strict.
Move on to the next section: Layout Types
