| |
| Overview |
| |
In this chapter you will learn
- Definition of XHTML
- Differences between HTML and XHTML
- Basic tags in XHTML
- How a basic web page is created
|
| |
| Introduction |
| |
This tutorial provides a brief know-how about XHTML. It defines the basic characteristics of XHTML, the concepts and terms related to it. XHTML is an acronym for Extended Hypertext Markup Language. It is necessary to be familiar with HTML before going into the details of XHTML as XHTML is said to be the successor to HTML.
XHTML is a newer version of HTML, some web designers prefer to call it a stricter version of HTML. XHTML has been developed with the idea of reducing incompatibilities between different browsers.
XHTML is much easier to work on than HTML. Its uses are very similar to the uses of HTML. But there are some basic differences between the two, which are stated below.
|
| |
| Differences between HTML and XHTML |
| |
- In XHTML, all tags are written in lowercase. It does not support tags in uppercase.
- Some of the tags, used in HTML are deprecated in XHTML.
- Some attributes of HTML tags are not supported by XHTML.
- All tags, including empty elements that are opened in XHTML must be closed properly.
- XHTML tags must be properly nested. This means if there are multiple tags in the page, all of them should be opened and closed in the correct order.
- Pages written in XHTML are compatible with most browsers.
|
| |
| Document Structure |
| |
The document structure of XHTML resembles the document structure of HTML. Like HTML, XHTML documents are structured into four basic tags. These tags are: |
| |
| HTML |
The <html> tag is placed at the beginning and end of a document. Everything in the document goes inside the <HTML> tag. |
| |
| |
| HEAD |
The <head> tag contains general information about the document. It lies just below the <html> tag. It is like the cover page of a document containing general information about it. |
| |
| |
| TITLE |
The <title> tag specifies the title of a document. It is placed between the <head> tags. Each document can have only one title. |
| |
| |
| BODY |
The <body> tag contains the contents of a document. All text, headers, tables, headings, paragraphs, etc go into this tag. |
| |
| |
Basic Tags in XHTML |
| |
As has been already stated above, the tags in XHTML are very similar to HTML tags. The only difference is that all the tags are in lowercase and all opened tags have to be closed. |
| |
| Example |
<body> |
<p> Welcome to my web page. </p> |
|
| </body> |
| |
| HTML |
The first and last tag in an XHTML document is always the <html> tag. These tags tell the web browser that the file contains XHTML coded information. All other tags come between the <html> tags. The HTML tags look like: |
| |
| HEAD |
The <head> tag is the first part of XHTML coded document. It contains the title of the document. The title is shown as a part of the web browser. The HEAD tag looks like: |
| |
| Example |
<head>
<title> This is my page </title>
</head> |
| |
| |
| TITLE |
The <title> tag is contained within the <head> tags. This tag contains the title of the document. Each document can have only one title. The title of the document should be relevant to the content of the document. It is displayed in the title bar at the top of the browser window. The TITLE tag looks like this: |
| |
| Example |
<title> This is my first web page </title> |
| |
| |
| BODY |
The <body> tag contains the contents of a document. Everything visible on the web page is placed inside the <body> tag. All text, headers, tables, headings, paragraph, etc. go into this tag. The presentation attributes that were used in HTML are deprecated in XHTML. In XHTML, style sheets are used to employ all the attributes of <body> tag. The BODY tag looks like this:
|
| |
|