Sie sind auf Seite 1von 9

XHTML

?Why XHTML
Many pages contain BAD HTML
<html>
<head> <title>This is bad HTML</title>
<body>
<h1>Bad HTML
</body>

XML is a markup language where everything has


to be marked up correctly, which results in "well-
formed" documents
??So
XML was designed to describe data and HTML was designed to
display data
XHTML is a combination of HTML and XML (EXtensible
Markup Language)
XHTML consists of all the elements in HTML 4.01 combined
with the syntax of XML
Today's market consists of different browser technologies, some
browsers run Internet on computers, and some browsers run
Internet on mobile phones or other small devices. The last-
mentioned do not have the resources or power to interpret a
"bad" markup language
Therefore - by combining HTML and XML, and their strengths,
we got a markup language that is useful now and in the future -
XHTML
XHTML vs. HTML
XHTML elements must be
properly nested

HTML XHTML
<ul> <ul>
<li>Coffee</li> <li>Coffee</li>
<li>Tea <li>Tea
<ul> <ul>
<li>Black tea</li> <li>Black tea</li>
<li>Green tea</li> <li>Green tea</li>
</ul> </ul>
<li>Milk</li> </li>
</ul> <li>Milk</li>
</ul>
XHTML vs. HTML
XHTML Elements Must
Always Be Closed

XHTML
HTML
<p>This is a paragraph</p>
<p>This is a paragraph
<p>This is another
<p>This is another paragraph paragraph</p>

A break: <br> A break: <br />


A horizontal rule: <hr> A horizontal rule: <hr />
An image: <img src="happy.gif“ An image: <img
> src="happy.gif“ />
XHTML vs. HTML
XHTML Elements Must Be
In Lower Case

XHTML
HTML
<body>
<BODY>
<p>This is a paragraph</p>
<P>This is a paragraph</P>
</body>
</BODY>
XHTML vs. HTML
XHTML Documents Must Have One Root Element

<html>
<head> ... </head>
<body> ... </body>
</html>
XHTML more syntax rules
Attribute names must be in lower case
HTML: <table WIDTH="100%">
XHTML: <table width="100%">
Attribute values must be quoted
HTML: <table width=100%>
XHTML: <table width="100%">
Attribute minimization is forbidden
HTML: <input readonly>
XHTML: <input readonly=“readonly” />
XHTML more syntax rules
The id attribute replaces the name attribute
 HTML: <img src="picture.gif" name="picture1" />
 XHTML: <img src="picture.gif" id="picture1" />
The XHTML DTD defines mandatory elements
 All XHTML documents must have a DOCTYPE
declaration. The html, head and body elements must be
present, and the title must be present inside the head
element
<!DOCTYPE Doctype goes here>
<html xmlns="http://www.w3.org/1999/xhtml">
<head> <title>Title goes here</title> </head>
<body> </body>
</html>

Das könnte Ihnen auch gefallen