Introdução ao XHTML
- Página anterior Manual de consulta rápida do HTML
- Próxima página Elementos XHTML
XHTML 是以 XML 格式编写的 HTML。
XHTML is HTML written in XML format.
- What is XHTML?
- XHTML refers to 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 it in a browser, the following HTML code 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.
So - 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 mustcorrectly nested
- XHTML elements must alwaysclosed
- XHTML elements mustin lowercase
- An XHTML document must havea root element
attribute syntax
- XHTML attributes must usein lowercase
- The values of XHTML attributes must beEnclosed in quotes
- The minimization of XHTML attributes is alsoProhibited
The declaration <!DOCTYPE ....> is mandatory
An XHTML document must declare the XHTML document type (XHTML DOCTYPE declaration).
You can find the complete reference manual of tags on CodeW3C.com. XHTML document type.
The elements <html>, <head>, <title> and <body> must also exist, and must use the xmlns attribute in <html> to define the XML namespace for the document.
O exemplo a seguir mostra um documento XHTML com a menor quantidade de tags necessárias:
<!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>Título do documento</title> </head> <body> ...... </body> </html>
Como converter do HTML para XHTML
- Adicione o <!DOCTYPE> XHTML na primeira linha de cada página
- Adicione a propriedade xmlns ao elemento html de cada página
- Mude todos os nomes dos elementos para minúsculas
- Feche todos os elementos vazios
- Mude todos os nomes dos atributos para minúsculas
- Adicione aspas às todas as valores dos atributos
Verifique o XHTML com o validador W3C
Insira seu endereço da web no campo de texto abaixo:
Prova XHTML
Este teste contém 20 perguntas e não há limite de tempo.
Este teste é informal e é uma boa maneira de entender seu nível de conhecimento em XHTML.
Cada resposta correta vale 1 ponto. No final do teste, será exibida sua pontuação total. A pontuação máxima é de 20 pontos.
- Página anterior Manual de consulta rápida do HTML
- Próxima página Elementos XHTML