Extensible Hypertext Markup Language (XHTML)


HTML als XML Anwendung

XHTML10

Warum XHTML?

Bedingungen für XHTML konforme Dokumente

Beispiel

<?xml version="1.0"?>
<!DOCTYPE html 
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/strict.dtd">
<html xmlns="http://www.w3.org/TR/xhtml1">
<head>
<title>Browser Titel</title>
</head>
<body>
<h1>Dokument Titel</h1>
<p>
Ein Paragraph <br />
auf zwei Zeilen.
</p>
<math xmlns="http://www.w3.org/TR/REC-MathML">
   ... Text in MathML ...
</math>
</body>
</html>

Verhalten von XML User Agents (Browser)

Unterschiede zu HTML 4.0

Diese Datei in XHTML und als XML.

Tips und Hinweise

Die DTDs: Strict, Transitional, Frameset

Beispiele mit Strict DTD

Ausblick


HTML Tidy

Tidy-Logo alt
Tidy-Logo neu

Alternativen: http://validator.w3.org/, http://wave.webaim.org/.

Beispiele für die Arbeitsweise von HTML Tidy

Beispiel für schlechtes HTML bad.html und das Ergebnis nach Bearbeitung mit HTML Tidy good.html.

Fehlermeldungen aus dem Beispiel

> tidy  exam/bad.html >exam/good.html

Tidy (vers 19th October 1999) Parsing "exam/bad.html"
line 3 column 1 - Warning: inserting missing 'title' element
line 5 column 2 - Warning: replacing unexpected <h2> by </h1>
line 5 column 37 - Warning: discarding unexpected </h3>
line 7 column 42 - Warning: replacing unexpected </i> by </b>
line 8 column 15 - Warning: replacing unexpected </b> by </i>
line 10 column 45 - Warning: missing </i> before </h2>
line 12 column 4 - Warning: inserting implicit <i>
line 14 column 2 - Warning: missing </i> before <p>
line 14 column 4 - Warning: inserting implicit <i>
line 14 column 43 - Warning: discarding unexpected <a>
line 16 column 2 - Warning: missing </a> before <li>
line 16 column 2 - Warning: missing </i> before <li>
line 16 column 2 - Warning: inserting implicit <ul>
line 24 column 1 - Warning: unknown attribute "tidy"
line 30 column 1 - Warning: <img> lacks "alt" attribute

"exam/bad.html" appears to be HTML proprietary
15 warnings/errors were found!

The alt attribute should be used to give a short description
of an image; longer descriptions should be given with the
longdesc attribute which takes a URL linked to the description.
These measures are needed for people using non-graphical browsers.

For further advice on how to make your pages accessible
see "http://www.w3.org/WAI/GL". You may also want to try
"http://www.cast.org/bobby/" which is a free Web-based
service for checking URLs for accessibility.

HTML & CSS specifications are available from http://www.w3.org/
To learn more about Tidy see http://www.w3.org/People/Raggett/tidy/
Please send bug reports to Dave Raggett care of <html-tidy@w3.org>
Lobby your company to join W3C, see http://www.w3.org/Consortium

Aufruf und Verwendung von HTML Tidy

> tidy  [[options] files]*

tidy: file1 file2 ...
Utility to clean up & pretty print html files
see http://www.w3.org/People/Raggett/tidy/

options for tidy released on 19th October 1999
  -config <file>  set options from config file
  -indent or -i   indent element content
  -omit   or -o   omit optional endtags
  -wrap 72        wrap text at column 72 (default is 68)
  -upper  or -u   force tags to upper case (default is lower)
  -clean  or -c   replace font, nobr & center tags by CSS
  -raw            leave chars > 128 unchanged upon output
  -ascii          use ASCII for output, Latin-1 for input
  -latin1         use Latin-1 for both input and output
  -iso2022        use ISO2022 for both input and output
  -utf8           use UTF-8 for both input and output
  -mac            use the Apple MacRoman character set
  -numeric or -n  output numeric rather than named entities
  -modify or -m   to modify original files
  -errors or -e   only show errors
  -quiet or -q    suppress nonessential output
  -f <file>       write errors to <file>
  -xml            use this when input is wellformed xml
  -asxml          to convert html to wellformed xml
  -slides         to burst into slides on h2 elements
  -help   or -h   list command line options
Input/Output default to stdin/stdout respectively
Single letter options apart from -f may be combined
as in:  tidy -f errs.txt -imu foo.html
For further info on HTML see http://www.w3.org/MarkUp

Einige wichtige Optionen

markup: yes, no
Erzeugen des verbesserten Markups.
wrap: number
Zeilenumbruch bei angegebener Spalte. 0 = abgeschaltet.
input-xml: yes, no
Einlesen als XML.
output-xml: yes, no
Ausgabe von XML.
output-xhtml: yes, no
Ausgabe von XHTML.
doctype: omit, auto, strict, loose or <fpi>
Festlegen des DOCTYPE in der Ausgabe.
char-encoding: raw, ascii, latin1, utf8 or iso2022
Festlegen des Zeichensatzes in der Ausgabe.
fix-backslash: yes, no
Wandelt "\" in URLs zu "/".
word-2000: yes, no
Versucht Müll, der von Word 2000 produziert wird zu entfernen.
clean: yes, no
Versucht überflüssigen Präsentations-Markup durch Stilregeln (CSS) oder Struktur-Markup zu ersetzen.
logical-emphasis: yes, no
Ersetzt i durch em, b durch strong, impliziert clean.
enclose-text: yes, no
Fasst Text auf Body-Level in Paragraphen. Wichtig für funktionierende Stilvorlagen.
split: yes, no
Teilt die Datei an h2 Elementen in einzelne "Folien".
new-empty-tags: tag1, tag2, tag3
new-inline-tags: tag1, tag2, tag3
new-blocklevel-tags: tag1, tag2, tag3
new-pre-tags: tag1, tag2, tag3
Definition von neuen Tags der entsprechenden Art.

Beispiel für ein Config-File

/* HTML Tidy configuration file */
markup: yes
wrap: 0
doctype: strict
break-before-br: yes
logical-emphasis: yes
enclose-text: yes
/* eof */

Was bei Tidy in Arbeit ist:


XHTML Basic 1.0

Reduktion von XHTML 1.0 auf die Elemente und Attribute, die auch auf kleinen Geräten angezeigt werden können. Zum Beispiel

Die gemeinsame Fähigkeiten dieser einfachen UAs ermöglichen folgende XHTML Elemente.

Elemente und Attribute, die nur auf aktuellen grafischen (PC-) Systemen funktionieren sind weggelassen.

Der Document Type ist

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
    "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">

Definierte Module

Structure Module*
body, head, html, title
Text Module*
abbr, acronym, address, blockquote, br, cite, code, dfn, div, em, h1, h2, h3, h4, h5, h6, kbd, p, pre, q, samp, span, strong, var
Hypertext Module*
a
List Module*
dl, dt, dd, ol, ul, li
Basic Forms Module
form, input, label, select, option, textarea
Basic Tables Module
caption, table, td, th, tr
Image Module
img
Object Module
object, param
Metainformation Module
meta
Link Module
link
Base Module
base

(*) = diese Module müssen bei XHTML Basic 1.0 mindestens unterstützt werden.

XHTML Basic 1.0 konformes Beispiel


XHTML 1.1 - Modul basiertes XHTML

Neuordnung von striktem XHTML 1.0 mit Hilfe von Modulen. Der Dokumenttyp ist

<!DOCTYPE
 html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

Definierte Module

Structure Module*
body, head, html, title
Text Module*
abbr, acronym, address, blockquote, br, cite, code, dfn, div, em, h1, h2, h3, h4, h5, h6, kbd, p, pre, q, samp, span, strong, var
Hypertext Module*
a
List Module*
dl, dt, dd, ol, ul, li
Object Module
object, param
Presentation Module
b, big, hr, i, small, sub, sup, tt
Edit Module
del, ins
Bidirectional Text Module
bdo
Forms Module
button, fieldset, form, input, label, legend, select, optgroup, option, textarea
Table Module
caption, col, colgroup, table, tbody, td, tfoot, th, thead, tr
Image Module
img
Client-side Image Map Module
area, map
Server-side Image Map Module
Attribut ismap von img
Intrinsic Events Module
Event Attributes
Metainformation Module
meta
Scripting Module
noscript, script
Stylesheet Module
style element
Style Attribute Module Deprecated
style attribute
Link Module
link
Base Module
base
Ruby Annotation Module
ruby, rbc, rtc, rb, rt, rp

Weitere Änderungen gegenüber XHTML 1.0 Strict sind: lang wird ersetzt durch xml:lang und name wird ersetzt durch id.

XHTML 1.1 konforme Beispiele: basic, alles.


© Universität Mannheim, Rechenzentrum, 1998-2006.

Heinz Kredel

Last modified: Mon Aug 21 12:35:10 CEST 2006