XHTML-Übersicht
- Vorherige Seite HTML Schnellhandbuch
- Nächste Seite XHTML Elemente
XHTML 是以 XML 格式编写的 HTML。
XHTML is HTML written in XML format.
- What is XHTML?
- XHTML stands for Extensible Hypertext Markup Language
- XHTML is almost the same as HTML 4.01
- XHTML is a stricter and purer version of HTML
- XHTML is defined as HTML applied in the way of XML XHTML isJanuary 2001
- Published W3C recommended standard
XHTML is supported by all mainstream browsers
Why use XHTML?
Many web pages on the Internet contain 'bad' HTML.
If you view the following HTML code in a browser, it runs very normally (even though it does not comply with HTML rules): <head> <html> <body> <title>This is bad HTML</title> <h1>Bad HTML </body>
<p>This is a paragraph
XML is a markup language that must be properly marked and well-formed. If you want to learn XML, please read our.
XML tutorial
In today's technology industry, there are some different browser technologies. Some run on computers, while others may run on mobile phones or other small devices. Small devices often lack the resources and capabilities to interpret 'bad' markup languages.
Therefore - by combining the strengths of XML and HTML, XHTML was developed. XHTML is a re-designed HTML as XML.
The most important difference compared to HTML:
- document structuremandatory
- The XHTML DOCTYPE ismandatory
- The XML namespace attribute in <html> is alsomandatory
element syntax
- XHTML elements mustbe correctly nested
- XHTML elements must alwaysbe closed
- XHTML elements mustlowercase
- An XHTML document must havea root element
attribute syntax
- XHTML attributes must uselowercase
- The values of XHTML attributes must be enclosed insurrounded by quotes
- The minimization of XHTML attributes is alsoProhibited
The declaration <!DOCTYPE ....> is mandatory
An XHTML document must have an XHTML document type declaration (XHTML DOCTYPE declaration).
You can find the complete reference in the CodeW3C.com tag manual. XHTML document type.
The elements <html>, <head>, <title> and <body> must also exist, and the xmlns attribute in <html> must be used to define the XML namespace for the document.
Der folgende Beispiel zeigt ein XHTML-Dokument mit den wenigsten erforderlichen Tags:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Titel des Dokuments</title> </head> <body> ...... </body> </html>
Wie man von HTML zu XHTML konvertiert
- Fügen Sie jedem ersten Zeilen der Seite das XHTML <!DOCTYPE> hinzufügen
- Fügen Sie jedem html-Element auf jeder Seite die xmlns-Attribut hinzufügen
- Verwenden Sie alle Elementnamen in Kleinbuchstaben
- Schließen Sie alle leeren Elemente
- Verwenden Sie alle Attributnamen in Kleinbuchstaben
- Fügen Sie Anführungszeichen zu allen Attributwerten hinzu
Verwenden Sie den W3C Validator, um XHTML zu überprüfen
Geben Sie Ihre Website-URL im folgenden Textfeld ein:
XHTML Test
Dieser Test enthält 20 Fragen und hat keine Zeitbegrenzung.
Dieser Test ist nicht formell und ist nur ein guter Weg, um Ihr Wissen über XHTML zu überprüfen.
Jede richtige Antwort bringt 1 Punkt. Am Ende des Tests wird Ihre Gesamtpunktzahl angezeigt. Der Höchstwert beträgt 20 Punkte.
- Vorherige Seite HTML Schnellhandbuch
- Nächste Seite XHTML Elemente