HTML Tutorial - Part 5 XHTML Coding
You can use this HTML tutorial to learn the basics of this widely used mark-up language. This section tells you about XHTML requirements, headings, and how to build a web page with good form. An XHTML document is the same as an HTML document except we are going to add some more verbiage (...code). No need to be alarmed --- its not complicated. Once you know how to structure an XHTML doc you'll be on your way to learning lots more in the XHTML world. It'll be a snap! Learning how to use some common HTML tags and XHTML tags will increase your ability to create a web page.
- What Are The XHTML Requirements?
First we will add the <!DOCTYPE> tag. This is placed at the beginning of your file. It will indicate to your browser that this is an HTML file that conforms to the XHTML standard requirements.A typical <!DOCTYPE> tap will look like this... <!DOCTYPE html PUBLIC " - //W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1 - transitional.dtd"> ...and the HTML tag itself is different in an XHTML document. We need to add the following attributes to it: xmlns xml:lang lang With these added attributes the HTML tag is now structured like this... <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> - You probably noticed that the letters in <!DOCTYPE> are all in caps -- this tag should aways be in caps. Also, an exclamation must appear before the word DOCTYPE.
- An XHTML web page requires a full <html> tag;
<html ... lang="en">. The HTML web only requires the <html> tag. - When we use the xmlns attribute it links the document to the W3C's definition of the always evolving XHTML language.
- To recap, remember that for an XHTML web page the <!DOCTYPE...> tag must be at the top and the full <html> tag is used.
- <!DOCTYPE> Variations
There are three types of <!DOCTYPE...> tags... Strict, Frameset, and Transitional.
Note: You may want to indent some of your code if that makes it easier to read. I've chosen not to indent through out most of this HTML tutorial because of the screen limitations a some of my visitor's equipment.It's your choice of course -- what ever makes you comfortable. |
- XHTML Configuration
Let's create your first the XHTML web page. Again you do not have create a new file unless you want to. Modify the existing HTML code. The modified code should look like this in your text editor… <!DOCTYPE html PUBLIC " - //W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1 - transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>My XHTML Web Page</title> </head> <body> This sentence will be displayed on my XHTML web page. </body> </html>
- Save the file in a folder -- remember to use lowercase characters with an extension type of either .htm or .html.
Browse it.

- When you add the XHTML code to the file it does not change the appearance. In this example only the <title> tags and the sentence within the <body> tags was modified.
- In the next section of this HTML tutorial we'll explore some more widely used tags.
Return from HTML Tutorial Part 5.

|