Search Helium

Home > Computers & Technology > Internet > Web Design

The key differences between HTML and XHTML

by Avinash Mendha

Created on: March 14, 2009   Last Updated: March 29, 2009

HTML (Hyper Text Markup Language) is rapidly being replaced by XHTML(Extensible Hyper Text Markup Language). The differences are quiet few,but the results of switching from HTML to XTML is worth the effort. The benefit of XHTML is that it is widely accepted in 'non-computer' devices like cellphones and scaled down browsers. This is known as portability of devices. XHTML is said to be Extensible, which is fancy way of saying the new tags can be added without a new document type declaration. Tags used in XHTML are strict in behaviour. So before using XHTML a person should be familiar with HTML and its tags completely.

Key differences between HTML & XHTML :

1)The tags in the page MUST be in lowercase so instead of <HTML><BODY> , as we would use in HTML, we use instead <html><body>.

2)All the tags which are opened should be closed (<p> </p>). In HTML,many of these tags were simply left open.

3)All tags must be nested properly,so if you start tag 'a' and then start tag 'b' then you must first close tag 'b' before you close tag 'a'.

4)All the attributes must also be in lowercase.

5)All the values of attributes must be enclosed in single or double quotes.

6)Structure must be seperated from content. For example,the <p> tag is content tag (paragraph), so you can't put a table in it, because a table is a format construct. You can however put <p> tag inside <td></td> tags with no problem, because the content goes with construct, not the other way around.

7)Some tags which were previously allowed are no longer allowed,see the discussion below of DTD ( Document Type Declaration ).

The first thing you will notice if you look at sourse of XHTML is the first line is DTD ( Document Type Declaration ) also called as DOCTYPE. There are three DTD's that are used, strict (that will only validate if you have no deprecaed tags), transitional (which will still validate with deprecated tags) and frameset (which is for the page which has frames). Although all tags in XHTML are in lowercase, DTD must be declared in uppercase. The three DTD's look as given below:

1) Strict :

<!DOCTYPE html PUBLIC "-//W4//DTD XHTML 1.0 Strict//EN" "DTD/strict.dtd">

2)Transitional :

<!DOCTYPE html PUBLIC "-//W4//DTD XHTML 1.0 Transitional//EN" "/DTD/transitional.dtd">

3)Frameset :

<!DOCTYPE html PUBLIC "-//W4//DTD XHTML 1.0 Frameset//EN" "DTD/frameset.dtd">

These were the basic rules or the differences of XHTML from HTML. These tips will surely help you in building a simple webpage using XHTML.

Learn more about this author, Avinash Mendha.
Click here to send this author comments or questions.

Helium Debate

Cast your vote!

Is what Wikileaks does, journalism?

Click for your side.

175649

Featured Partner

National Center for Policy Analysis (NCPA)

The National Center for Policy Analysis (NCPA) has partnered with Helium, giving you the chance to write for a cause. Browse NCPA's featured titles, pick an issue and write! You can also learn new perspectives on issues that yo...more


CONNECT WITH US

Read
our blog
Helum for writers

Write and get published
Share with other writers
Polish your freelancing skills

Join our active writing community
Helium Content Source for Publishers

Quality articles from proven freelancers
Exclusive rights, fast turnaround
Brand engagement, business blogging -- our writers do it all

Get custom content today!

INFORMATION


Helium, Inc.
200 Brickstone Square Andover, MA 01810 USA
#