I am developing a website, and I have no web designing or computer programming knowledge. After reading up on web design, I have found out that I should use XHTML over HTML. I was just wondering whether I need to learn HTML to understand XHTML.

Let's put it this way - HTML is a large subset of XHTML - learn one and you've pretty much learned the other.

General Rules for converting HTML to XHTML

* The first line in the HTML document may be the XML processing instruction:

<?xml version="1.0" encoding="iso-8859-1"?>

W3C recommends that this declaration be included in all XHTML documents, although it is absolutely required only when the character encoding of the document is other than the default Unicode UTF-8 or UTF-16. I said necessary because there can be problems with older browsers which cannot identify this as a valid HTML tag.

* The second line in the XHTML document should be the specification of the document type declaration (DTD) used. The document type declaration for transitional XHTML documents is:

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

The declarations for the strict XHTML DTD is:

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

The declarations for the frameset XHTML DTD is:

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

* XML requires that there must be one and only one root element for a document. Hence, in XHTML, all tags should be enclosed within the <html> tag, ie., <html> should be the root element for the document.
* The starting tag <html> should be modified to include namespace information. The modification is:

<html xmlns="http://www.w3.org/1999/xhtml" lang="EN">


Attribute xmlns is the XML namespace with which we associate the XHTML document. The value of the attribute lang is the code for the language of the document as specified in RFC1766.
* All XHTML tag elements should be in lower case. That means <HTML> and <Body> are wrong. They should be rewritten as <html> and <body> respectively.
* All XHTML tags should have their end tags. In HTML it is common for paragraphs to have only the starting <p> tag. In XHTML this is not allowed. You need to end a paragraph with the </p> tag. Example: <p>Hello is wrong; it should be written as <p>Hello</p>.
* Empty XHTML tags should be ended with /> instead of >. The commonly used empty tags in XHTML are:
1. <meta />: for meta information (contained in the head section).
2. <base />: used to specify the base URI and also the target frame for hyperlinks (contained in the head section).
3. <basefont />: used to specify a base font for the document. Note that attribute 'size' is mandatory.
4. <param />: parameters for applets and objects.
5. <link />: to specify external stylesheets and other references.
6. <img />: to include images. Attributes 'src' for the source URI and 'alt' for alternate text are mandatory.
7. <br />: used for forced line break.
8. <hr />: for horizontal rules.
9. <area />: used inside image maps. Attribute 'alt' is mandatory.
10. <input />: used inside forms for input form elements like buttons, textboxes, textareas, checkboxes and radio buttons.

Example: <br clear="all"> is wrong; it should be rewritten as <br clear="all" />. <img src="back.gif" alt="Back"> is wrong; it should be <img src="back.gif" alt="Back" />

* Proper nesting of tags is compulsory in XHTML. Example: <b><i>This is bold italics</b><i> is wrong. It should be rewritten as <b><i>This is bold italics</i><b>.

web designers

So, learn XHTML and CSS and all your bases are covered. - But I've noticed that many of the newer HTML books cover XHTML as well.

XHTML is a stricter and cleaner version of HTML.so also learn XHTML than HTML.

If you're just being a designer, and you're not gonna work that much with HTML, then IMHO regular HTML is just fine. If you want to be a developer, you should probably learn XHTML, since that's going to work much better, and is way cleaner.

XHTML requires good coding practices. Good coding practices are the first step in ensuring that what you've designed is what your viewer will see. (At least close - there's no accounting for the people viewing your beautiful design on their phone and then complaining that it's too whatever... or who haven't updated their browser for the past ten years. But that's a different rant.)

There's quite a bit of confusion as to what XHTML is for and when you should use it. XHTML is a more strict HTML, but it is by no means a new version of HTML - they are in fact used for different things.

XHTML is used to serve XML data. XML is not HTML, and unless you are using XML in your document an HTML doctype should be used.

Have a look at this for more information on which doctype should be used.

Regards
Arkinder

I would just skip XHTML/HTML and go straigt to HTML5, everything is moving towards HTML5.

which is basic difference between HTML OR XHTML..
I need to know what is the different between HTML and XHTML. Is XHTML have more tags than HTML.

XHTML is a broader, more powerful language than HTML with stricter rules - beginning with declaring what type of document it is. XHTML also uses CSS for styling as it is designed to have content separate from style. Vernonewd (above) has given a nice synopsis of the differences.

my understanding is that the only real major differences are in the doctype, and that XHTML is more strict, little margin for error, then HTML.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.