Introduction To XHTML
Introduction To XHTML
What Is XHTML?
XHTML stands for EXtensible HyperText Markup Language XHTML is almost identical to HTML 4.01 XHTML is a stricter and cleaner version of HTML XHTML is HTML defined as an XML application XHTML is a W3C Recommendation All Browsers Support XHTML
Why XHTML?
Many pages on the internet contain "bad" HTML. <html> <head> <title>This is bad HTML</title> <body> <h1>Bad HTML <p>This is a paragraph </body>
XML is a markup language where everything must be marked up correctly, which results in "well-formed" documents. XML is designed to describe data, and HTML is designed to display data.
XHTML elements must be properly nested XHTML elements must always be closed XHTML elements must be in lowercase XHTML documents must have one root element
XHTML:
<b><i>This
Correct:
<p>This
Wrong:
A break: <br> A horizontal rule: <hr> An image: <img src="happy.gif" alt="Happy face"> break: <br /> A horizontal rule: <hr /> An image: <img src="happy.gif" alt="Happy face" />
Correct:
A
Wrong:
<BODY>
Correct:
<body>
XHTML Syntax
Attribute names must be in lower case Attribute values must be quoted Attribute minimization is forbidden The XHTML DTD defines mandatory elements
Correct:
Wrong:
<input
An XHTML document must have a DOCTYPE declaration. The html, head, title, and body elements must also be present.
XHTML Doctypes
An XHTML Example
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Title of document</title> </head> <body> </body>
The <!DOCTYPE> declaration is the very first thing in an XHTML document, before the <html> tag. The <!DOCTYPE> declaration is not an XHTML tag; it is an instruction to the web browser about what version of the markup language the page is written in.
The <!DOCTYPE> declaration refers to a Document Type Definition (DTD). The DTD specifies the rules for the markup LDCU | College of Information Technology language, so that the browsers render
XHTML 1.0 Strict XHTML 1.0 Transitional XHTML 1.0 Frameset XHTML 1.1
This DTD contains all HTML elements and attributes, but does NOT INCLUDE presentational or deprecated elements (like font). Framesets are not allowed. The markup must also be written as well-formed XML.
This DTD contains all HTML elements and attributes, INCLUDING presentational and deprecated elements (like font). Framesets are not allowed. The markup must also be written as wellformed XML. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtm l1-transitional.dtd">
This DTD is equal to XHTML 1.0 Transitional, but allows the use of frameset content. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtm l1-frameset.dtd">
XHTML 1.1
This DTD is equal to XHTML 1.0 Strict, but allows you to add modules (for example to provide ruby support for East-Asian languages). <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xht ml11.dtd">
XHTML Summary
This lecture has taught you how to create stricter and cleaner HTML pages. You have learned that all XHTML elements must be properly nested, XHTML documents must be well-formed, all tag names must be in lowercase, and that all XHTML elements must be closed.
You have also learned that all XHTML documents must have a <!DOCTYPE> declaration, and that the html, head, LDCU | College of Information Technology title, and body elements must be
The next step is to learn CSS. CSS is used to control the style and layout of multiple Web pages all at once. With CSS, all formatting can be removed from the HTML document and stored in a separate file. CSS gives you total control of the layout, without messing up the document content.
Questions?
Thank You!
Reference:
http://w3schools.com/xhtml/default.asp