Tutorial: Introduction to XHTML
Author: Martin Warning
Year: 2007
Page: 1
Introduction
XHTML, like HTML, is a programming language to create webpages. XHTML works together with CSS to create fully formatted pages. With JavaScript you can make dynamic (DHTML/Ajax) webpages with which the user can interact. With a server side programming language (ASP/PHP/JSP) you can create pages that can interact with a database.
XML
XHTML is a XML programming language. By comparison HTML is a SGML language. The benefits of XML are numerous and include the fact that XML is a meta-language written for the internet. As XHTML is a XML language the rules are stricter applied than with HTML, but this leads to better coded pages and more cross browser support for your website.
Presentation Separated from Structure
XML results in a conceptual change where the structure of the document is separated from the presentation like most other programming languages. With HTML both structure and presentation are often written in the same code. With XHTML you write the structure of the document in XHTML and the presentation of the document with CSS. This can also be done with HTML and in fact almost all of XHTML can be done much the same way in HTML.
Changes from HTML
Besides that several HTML elements like <font> are depreciated in XHTML in favor of CSS, there are some other changes as well. All XHTML code has to be written in lower case, this includes elements as well as element attributes. Attribute values can be lower case as well as upper case. Another change is that each element that is opened has to be closed. Some elements like <li> are now closed after it's content. Other elements don't contain content and as such don't have a closing element. These elements will have to be closed in within the opening element with / like <br />.
Nesting
XHTML like HTML allows elements to be nested within other elements. When opening an element (child) inside of another (parent) element the child element needs to be closed before the parent element.
Code, incorrect nesting:<b><i>content</b></i>Code, correct nesting:
<b><i>content</i></b>Future
The next version of HTML/XHTML will be HTML 5 which will incorporate the more strict regimen of XHTML, but based on HTML 4. It will add many more structure tags than currently available in either HTML or XHTML and will be more strict about seperating structure and presentation.
Index:
Page 1: Introduction
Page 2: Document: Doctype
Page 3: Document: <html>
Page 4: Header: <head>
Page 5: Header: <title>
Page 6: Body: <body>
Summary