XHTML: diferenças entre revisões

Conteúdo apagado Conteúdo adicionado
→‎XHTML 1.0: Adequando ao !DOCTYPE --> "xhtml1-frameset.dtd"
m +fix -redirect (com WCleaner) - Apple (v1.13)
Linha 5:
|screenshot =
|legenda =
|extensão = .xhtml<span style="font-family: sans-serif;">,</span> .xht<span style="font-family: sans-serif;">,</span> .html<span style="font-family: sans-serif;">,</span> .htm
|mime = application/xhtml+xml
|magica =
Linha 34:
 
== Exemplos ==
Um exemplo simples de XHTML seria: (Observando dentro das tags <html></html>)
 
<source lang="html4strict">
<html>
<head>
</head>
<body>
<form>
<fieldset>
<legend>Dados para Cadastro</legend>
<label for="nome">Nome:</label>
<input type="text" name="nome" id="nome" /><br />
<label for="tipo">Tipo:</label>
<input type="text" name="tipo" id="tipo" /><br />
<label for="data">Data:</label>
<input type="text" name="data" id="data" /><br />
<input type="submit" value="enviar" class="botao" />
</fieldset>
</form>
</body>
</html>
</source>
Linha 114:
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
</body>
</html>
</source>
 
* '''XHTML 1.0 Transitional''' é o mesmo que HTML 4.01 Transitional, mas segue as regras de sintaxe XML. Ele suporta tudo encontrado no XHTML 1.0 Strict, mas também permite o uso de vários elementos e atributos que são julgados ''presencionais'', para facilitar a transição de HTML 3.2 e mais recentes. Isso inclui <code><nowiki><center></nowiki></code>, <code><nowiki><u></nowiki></code>, <code><nowiki><strike></nowiki></code>, e <code><nowiki><applet></nowiki></code>.
 
Declaração da XHTML 1.0 Transitional:
Linha 132:
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
</body>
</html>
</source>
Linha 150:
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<frameset>
</frameset>
</html>
</source>
 
=== XHTML 1.1 ===
A mais recente Recomendação XHTML da W3C é o ''XHTML 1.1: Module-based XHTML'', que é uma reformulação do XHTML 1.0 Strict, com pequenas modificações, usando alguns módulos de um conjunto definido em Modularização de XHTML,<ref>[http://www.w3.org/TR/xhtml-modularization/ XHTML Modularization]</ref> uma Recomendação W3C que cria uma modularização de frames, um padrão de módulos, e várias outras definições. Todas as ferramentas depreciadas de HTML, como elementos presencionais e framesets, e até mesmo os atributos <code>lang</code> e o atributo de âncoras <code>name</code>, que ainda eram permitidos no XHTML 1.0 Strict, foram removidos desta versão. A apresentação é controlada puramente pelas [[Folhas de Estilo em Cascata]] ([[Cascading Style Sheets|CSS]]). Esta versão também permite suporte à marcação rubi, necessária para línguas do Extremo Oriente (especialmente [[CJK]]).
 
Além da Modularização de XHTML permitir pequenas ferramentas XHTML serem reutilizadas por outras aplicações XML de uma maneira bem definida, e que o XHTML seja estendido para alguns propósitos, XHTML 1.1 adiciona o conceito de um documento "estritamente conformado": esses documentos definidos nos módulos requeridos para XHTML 1.1. Por exemplo, se um documento é estendido para usar o módulo XHTML Frames (frameset), ele também pode ser descrito como XHTML 1.1, mas não ''estritamente conforme'' o XHTML 1.1. Ao invés disso, ele deve ser descrito como um XHTML Host Language Conforming Document,<ref>[http://www.w3.org/TR/2001/REC-xhtml-modularization-20010410/conformance.html#s_conform_document XHTML Host Language Conforming Document]</ref> se a ferramenta for relevante e necessária.
Linha 175:
* HTML frames will be replaced by [[XFrames]].
* The [[DOM Events]] will be replaced by [[XML Events]], which uses the XML [[Document Object Model]].
* A new list element type, the <code>nl</code> element type, will be included to specifically designate a list as a navigation list. This will be useful in creating nested menus, which are currently created by a wide variety of means like nested unordered lists or nested definition lists.
* Any element will be able to act as a [[hyperlink]], e.g., <code><nowiki><li href="articles.html">Articles</li></nowiki></code>, similar to [[XLink]]. However, XLink itself is not compatible with XHTML due to design differences.
* Any element will be able to reference alternative media with the <code><nowiki>src</nowiki></code> attribute, e.g., <code><nowiki><p src="lbridge.jpg" type="image/jpeg">London Bridge
 
</nowiki></code> is the same as <code><nowiki><object src="lbridge.jpg" type="image/jpeg">
 
London Bridge
 
</object></nowiki></code>.
* The <code>alt</code> attribute of the <code>img</code> element has been removed: alternative text will be given in the content of the <code>img</code> element, much like the <code>object</code> element, e.g., <code><nowiki><img src="hms_audacious.jpg">HMS <em>Audacious</em></img></nowiki></code>.
* A single heading element (<code>h</code>) will be added. The level of these headings will be indicated by the nested <code>section</code> elements, each with their own <code>h</code> heading.
* The remaining presentational elements <code>i</code>, <code>b</code> and <code>tt</code>, still allowed in XHTML 1.x (even Strict), will be absent from XHTML 2.0. The only somewhat presentational elements remaining will be <code>sup</code> and <code>sub</code> for superscript and subscript respectively, because they have significant non-presentational uses and are required by certain languages. All other tags are meant to be [[semantic]] instead (e.g. <code><nowiki>'''</nowiki></code> for '''strong or bolded''' text) while allowing the user agent to control the presentation of elements via CSS.
* The addition of RDF triple with the <code>property</code> and <code>about</code> attributes to facilitate the conversion from XHTML to RDF/XML.
-->
=== HTML5 (esboço) ===
Em [[10 de abril]] de [[2007]], a [[Fundação Mozilla]], [[Apple Inc.]] e [[Opera Software]] propuseram<ref>{{citar web
|url=http://lists.w3.org/Archives/Public/public-html/2007Apr/0429.html
|titulo=Proposal to Adopt HTML5 from Maciej Stachowiak on 2007-04-10 (public-html@w3.org from April 2007)
Linha 220:
 
; XHTML 1.0 Strict
: <code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"<br />"<nowiki>http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</nowiki>"&gt;</code>
; XHTML 1.0 Transitional
: <code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"<br />"<nowiki>http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</nowiki>"&gt;</code>
; XHTML 1.0 Frameset
: <code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"<br />"<nowiki>http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd</nowiki>"&gt;</code>
; XHTML 1.1
: <code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"<br />"<nowiki>http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd</nowiki>"&gt;</code>
; XHTML5
XHTML5 does not require a doctype, and XHTML5 validation is not DTD-based.
; XHTML 2.0
XHTML 2.0, [[As of August 2006]], is in a draft phase. If an XHTML 2.0 Recommendation is published with the same document type declaration as in the current Working Draft, the declaration will appear as:
: <code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 2.0//EN"<br
/>"<nowiki>http://www.w3.org/MarkUp/DTD/xhtml2.dtd</nowiki>"&gt;</code>
 
A placeholder DTD schema exists at the corresponding URI, though it currently only includes the character reference entities from previous recommendations. XHTML 2 contemplates both a <code>version</code> attribute and an <code>xsi:schemalocation</code> attribute on the root HTML element that could possibly serve as a substitute for any DOCTYPE declaration.
 
==== XML namespaces and schemas ====
In addition to the DOCTYPE, all XHTML elements must be in the appropriate [[XML namespace]] for the version being used. This is usually done by declaring a default namespace on the root element using <code>xmlns="namespace"</code> as in the example below.
 
For XHTML 1.0, XHTML 1.1 and XHTML5, this is
: <code>&lt;<nowiki>html xmlns="http://www.w3.org/1999/xhtml"</nowiki>&gt;</code>
 
XHTML 2.0 requires both a namespace and an [[XML Schema]] instance declaration. These might be declared as
: <code>&lt;html xmlns="<nowiki>http://www.w3.org/2002/06/xhtml2/</nowiki>"<br
/>xmlns:xsi="<nowiki>http://www.w3.org/2001/XMLSchema-instance</nowiki>"<br
/>xsi:schemaLocation="<nowiki>http://www.w3.org/2002/06/xhtml2/ http://www.w3.org/MarkUp/SCHEMA/xhtml2.xsd</nowiki>"&gt;</code>
 
This example for XHTML 2.0 also demonstrates the use of multiple namespaces within a document. The first <code>xmlns</code> default namespace declaration indicates that elements and attributes whose names have no XML namespace prefix fall within the XHTML 2.0 namespace. The second namespace prefix declaration <code>xmlns:xsi</code> indicates that any elements or attributes prefixed with the <code>xsi:</code> refer to the XMLSchema-Instance namespace. Through this namespace mechanism XML documents allow the use of a mixture of elements and attributes taken from various XML vocabularies while avoiding the potential for clashes of naming between items from independently developed vocabularies.
 
Similar to the case of DOCTYPE above, the actual URL to the [[XML Schema]] file can be changed, as long as the [[Universal Resource Identifier]] (URI) before it (which indicates the XHTML 2.0 namespace) remains the same. The namespace URI is intended to be a persistent and universally unique identifier for the particular version of the specification. If treated as a URL, the actual content located at the site is of no significance.
 
==== XML Declaration ====
A [[character encoding]] may be specified at the beginning of an XHTML document in the XML declaration when the document is served using the <code>application/xhtml+xml</code> MIME type. (If an XML document lacks encoding specification, an XML parser assumes that the encoding is [[UTF-8]] or [[UTF-16]], unless the encoding has already been determined by a higher protocol.)
 
For example:
 
: <code><?xml version="1.0" encoding="UTF-8"?></code>
 
The declaration may be optionally omitted because it declares as its encoding the default encoding. However, if the document instead makes use of XML 1.1 or another character encoding, a declaration is necessary. [[Internet Explorer]] prior to version 7 enters [[quirks mode]] if it encounters an XML declaration in a document served as <code>text/html</code>.
 
=== Common errors ===
Linha 264:
* Failing to realize that documents won’t be treated as XHTML unless they are served with an appropriate XML [[Internet media type|MIME type]]
* Not closing empty elements (elements without closing tags in HTML4)
** Incorrect: <code><nowiki><br /></nowiki></code>
** Correct: <code><nowiki><br /></nowiki></code><br />Note that any of these are acceptable in XHTML: <code>&lt;br&gt;&lt;/br&gt;</code>, <code>&lt;br/&gt;</code> and <code>&lt;br&nbsp;/&gt;</code>. Older HTML-only browsers will generally accept <code>&lt;br&gt;</code> and <code>&lt;br&nbsp;/&gt;</code>. Using <code>&lt;br&nbsp;/&gt;</code> gives some degree of backward and forward compatibility.
* Not closing non-empty elements
** Incorrect: <code><nowiki>
 
This is a paragraph.
 
This is another paragraph.</nowiki></code>
** Correct: <code><nowiki>
 
This is a paragraph.
Linha 280:
</nowiki></code>
* Improperly nesting elements (elements must be closed in reverse order)
** Incorrect: <code><nowiki><em>'''This is some text.</em>'''</nowiki></code>
** Correct: <code><nowiki><em>'''This is some text.'''</em></nowiki></code>
* Not putting quotation marks around attribute values
** Incorrect: <code><nowiki><td rowspan=3></nowiki></code>
** Correct: <code><nowiki><td rowspan="3"></nowiki></code>
** Correct: <code><nowiki><td rowspan='3'></nowiki></code>
* Using the ampersand outside of entities (use <code>&amp;amp;</code> to display the ampersand character)
** Incorrect: <code><nowiki><title>Cars &amp; Trucks</title></nowiki></code>
** Correct: <code><nowiki><title>Cars &amp;amp; Trucks</title></nowiki></code>
* Using the ampersand outside of entities in [[Uniform Resource Locator|URL]]s (use <code>&amp;amp;</code> instead of <code>&amp;</code> in links also)
** Incorrect: <code><nowiki><a href="index.php?page=news&amp;style=5">News</a></nowiki></code>
** Correct: <code><nowiki><a href="index.php?page=news&amp;amp;style=5">News</a></nowiki></code>
* Failing to recognize that XHTML elements and attributes are case sensitive
** Incorrect: <code><nowiki><BODY><P ID="ONE">The Best Page Ever
 
</BODY></nowiki></code>
** Correct: <code><nowiki><body><p id="ONE">The Best Page Ever
 
</body></nowiki></code>
* Using attribute minimization
** Incorrect: <code><nowiki><textarea readonly>READ-ONLY</textarea></nowiki></code>
** Correct: <code><nowiki><textarea readonly="readonly">READ-ONLY</textarea></nowiki></code>
* Mis-using CDATA, script-comments and xml-comments when embedding scripts and stylesheets.
** This problem can be avoided altogether by putting all script and stylesheet information into separate files and referring to them as follows in the XHTML <code>head</code> element.
<pre>
&lt;link rel="stylesheet" href="/style/screen.css" type="text/css" /&gt;
Linha 309:
</pre>
 
:: Note: The format <code>&lt;script …&gt;&lt;/script&gt;</code>, rather than the more concise <code>&lt;script … /&gt;</code>, is required for HTML compatibility when served as MIME type <code>text/html</code>.
** If an author chooses to include script or style data inline within an XHTML document, different approaches are recommended depending whether the author intends to serve the page as <code>application/xhtml+xml</code> and target only fully conformant browsers, or serve the page as <code>text/html</code> and try to obtain usability in Internet Explorer 6 and other non-conformant browsers.
 
:: In the fully conformant <code>application/xhtml+xml</code> case, the non-XML code is wrapped in a CDATA section as follows [http://www.w3.org/TR/xhtml1/#h-4.8]:
 
<pre><nowiki>
<style type="text/css">
<![CDATA[
p { color: green; }
]]>
</style>
&nbsp;
<script type="text/javascript">
<![CDATA[
function nothing() { }
]]>
</script>
</nowiki></pre>
 
:: If the same file may be served or processed as both XML (<code>application/xhtml+xml</code>) and HTML compatible <code>text/html</code> to target Internet Explorer 6 and as many other historic and non-conforming browsers as possible, constructs as complex as the following may be necessary[http://hixie.ch/advocacy/xhtml]:
 
<pre><nowiki>
<style type="text/css">
<!--/*-- ><![CDATA[/*><!--*/
p { color: green; }
/*]]>*/-- >
</style>
&nbsp;
<script type="text/javascript">
<!--//-- ><![CDATA[//><!--
function nothing() { }
//-- ><!]]>
</script>
</nowiki></pre>
 
Linha 347:
 
<pre><nowiki>
<style type="text/css">
/*<![CDATA[*/
p { color: green; }
/*]]>*/
</style>
&nbsp;
<script type="text/javascript">
//<![CDATA[
function nothing() { }
//]]>
</script>
</nowiki></pre>
 
== Backward compatibility ==
XHTML 1.0 documents are mostly backward compatible with HTML — that is, processible as HTML by a web browser that does not know how to properly handle XHTML — when authored according to certain guidelines given in the specification and served as <tt>text/html</tt>. Authors who follow the compatibility guidelines essentially create HTML documents that, while technically invalid, are processible by all modern web browsers.
 
Documents following the compatibility guidelines are still not truly compatible with HTML user agents that support the [[SGML]] ''NET'' (Null End Tag) construct, although very few user agents support it in practice. [[OpenSP]] is one such user agent.
Linha 396:
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>XHTML 1.0 Example</title>
<script type="text/javascript">
<!--//-- ><![CDATA[//><!--
function loadpdf() {
document.getElementById("pdf-object").src="http://www.w3.org/TR/xhtml1/xhtml1.pdf";
}
//-- ><!]]>
</script>
</head>
<body onload="loadpdf()">
 
This is an example of an
<abbr title="Extensible HyperText Markup Language">XHTML</abbr> 1.0 Strict document.<br />
<img id="validation-icon"
src="http://www.w3.org/Icons/valid-xhtml10"
alt="Valid XHTML 1.0 Strict" /><br />
<object id="pdf-object"
name="pdf-object"
type="application/pdf"
Linha 421:
width="100%"
height="500">
</object>
 
</body>
</html>
</source>
Linha 434:
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>XHTML 1.0 Example</title>
<script type="text/javascript">
<![CDATA[
function loadpdf() {
document.getElementById("pdf-object").src="http://www.w3.org/TR/xhtml1/xhtml1.pdf";
}
]]>
</script>
</head>
<body onload="loadpdf()">
 
This is an example of an
<abbr title="Extensible HyperText Markup Language">XHTML</abbr> 1.0 Strict document.<br />
<img id="validation-icon"
src="http://www.w3.org/Icons/valid-xhtml10"
alt="Valid XHTML 1.0 Strict"/><br />
<object id="pdf-object"
name="pdf-object"
type="application/pdf"
Linha 460:
 
</body>
</html>
</source>
Linha 466:
Notes:
# For further information on the media type recommendation, please refer to [http://www.w3.org/TR/2002/NOTE-xhtml-media-types-20020801/ XHTML Media Types], a W3C Note issued on 2002-08-01.
# The "loadpdf" function is actually a workaround for Internet Explorer. It can be replaced by adding <code><nowiki><param name="src" value="http://www.w3.org/TR/xhtml1/xhtml1.pdf" /></nowiki></code> within <code><nowiki><object></nowiki></code>.
# The <code>img</code> element does not get a <code>name</code> attribute in the [http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_XHTML-1.0-Strict XHTML 1.0 Strict DTD]. Use <code>id</code> instead.
-->
 
Linha 493:
{{Referências}}
 
== {{Ver também}} ==
* [[HTML]]
* [[XML]]
Linha 499:
* [[Cascading Style Sheets]]
 
== {{Ligações externas}} ==
{{Wikilivros|Curso de HTML}}
* {{link|en|http://www.w3.org/MarkUp/|W3C's XHTML}}