Bonnes Pratiques Web & Cloud
58.9K views | +1 today
Follow
Bonnes Pratiques Web & Cloud
Administration cloud et développement web
Curated by Mickael Ruau
Your new post is loading...
Your new post is loading...

Popular Tags

Current selected tag: 'xhtml'. Clear
Scooped by Mickael Ruau
Scoop.it!

Passer du HTML au XHTML | Openweb.eu.org

Passer du HTML au XHTML | Openweb.eu.org | Bonnes Pratiques Web & Cloud | Scoop.it
Les règles à suivre pour passer de la syntaxe HTML à la norme XHTML. Introduction Depuis le 26 janvier 2000, le XHTML est la nouvelle norme du (...)
No comment yet.
Scooped by Mickael Ruau
Scoop.it!

Polyglot Markup: A robust profile of the HTML5 vocabulary

Polyglot Markup: A robust profile of the HTML5 vocabulary | Bonnes Pratiques Web & Cloud | Scoop.it

A document that uses polyglot markup is a document that is a stream of bytes that parses into identical document trees (with some exceptions, as noted in the Introduction) when processed as HTML and when processed as XML. Polyglot markup that meets a well-defined set of constraints is interpreted as compatible, regardless of whether they are processed as HTML or as XHTML, per the HTML5 specification. Polyglot markup uses a specific DOCTYPE, namespace declarations, and a specific case—normally lower case but occasionally camel case—for element and attribute names. Polyglot markup uses lower case for certain attribute values. Further constraints include those on void elements, named entity references, and the use of scripts and style.

 
Mickael Ruau's insight:
Principles

Polyglot markup results in:

a valid HTML document. [HTML5]a well-formed XML document. [XML10]identical DOMs when processed as HTML and when processed as XML, with some notable exceptions: HTML and XML parsers generate different DOMs for somexml (xml:lang, xml:space, and xml:base), xmlns (xmlns="" and xmlns:xlink=""), and xlink (such as xlink:href) attributes. XML requires and HTML5 permits these attributes in certain locations and the attributes are preserved by HTML parsers. The exception must not break the requiremetn to be a valid HTML document.

Polyglot markup is not constrained:

to be valid XML. [XML10]by conformance to any XML DTD.

Polyglot markup is scripted according to the rules of XML (does not use document.write, for example) and excludes HTML elements that are impossible to replicate in an XML parser (does not use the noscript element, for example). Polyglot markup triggers non-quirks mode in HTML parsers, as non-quirks mode is closest to XML-mode rendering, in regard to both DOM and CSS. Polyglot markup results in the same encoding and the same language in both HTML-mode and XML-mode.

Polyglot markup, itself being valid HTML5, supports extensibility as it is defined in Section 2.2.3 Extensibility of HTML5, so long as the extension does not violate the rules of polyglot markup. [HTML5] In addition, being well formed XML, polyglot markup can be extended when it is served as application/xhtml+xml.

 
No comment yet.
Scooped by Mickael Ruau
Scoop.it!

Have You Considered Polyglot Markup? - SitePoint

Have You Considered Polyglot Markup? - SitePoint | Bonnes Pratiques Web & Cloud | Scoop.it
Did you know web documents can be both HTML and XML-based at the same time? This is what's known as polyglot markup.
Mickael Ruau's insight:

By doing this, your documents will almost assuredly be better structured and of higher quality, yet still be able to be treated as HTML5. Another benefit is that they can be processed by XML tools. Also, if you need HTML and XHTML versions of a page, then you won’t need to maintain two different copies of content (which is almost always a bad idea). With a polyglot document, you can serve it as HTML when you need to or as XHTML when you need to, without changing any content in the document.

 

Going back to the idea of identical DOMs (Document Object Models), remember that this is critical because browsers don’t render HTML directly. Instead they create a DOM from the document source and render that. Also, it’s the DOM that is manipulated by CSS and JavaScript. If different DOMs are created, then documents might render differently, especially if using CSS or JavaScript causes inconsistent changes to the different DOMs. Therefore, many of the guidelines are for the purpose of making sure that identical DOMs are maintained regardless of the parser being used to parse the polyglot document.

No comment yet.
Scooped by Mickael Ruau
Scoop.it!

HTML5 or XHTML? Polyglot Documents Mean You Don't Have To Choose

HTML5 or XHTML? Polyglot Documents Mean You Don't Have To Choose | Bonnes Pratiques Web & Cloud | Scoop.it
An introduction to polyglot documents: those that parse as both XML or HTML
Mickael Ruau's insight:

So what I wanted to do today was to make a few changes so that my Web pages could be parsed aseither HTML5 or XML (remember the point of XHTML, it's HTML encoded in XML). My reference for all this is Polyglot Markup: HTML-Compatible XHTML Documents.

 

As W3C documents go it's remarkably short. The first line of the abstract tells you what it's about:

A document that uses polyglot markup is a document that is a stream of bytes that parses into identical document trees (with the exception of the xmlns attribute on the root element) when processed as HTML and when processed as XML.

 

So, if an XML parser happens to wander into my bit of Web space, it'll be happy, as will an HTML parser. Importantly, they will derive an identical DOM.

 

Remember that browsers don't render HTML directly. They create a DOM from the HTML and render that (it's the DOM you manipulate with JavaScript).

 

Incidentally, notice that the aim is to please both an HTML and an XML parser, not an XHTML parser. Polyglot documents are not valid XHTML.

 

All of which sounds terribly complicated, not to say arcane, but let me cut to the chase. The first steps I took today were:

add in the XHTML namespace on the root element, i.e. the html element;add in an xml:lang attribute;make the word doctype uppercase. 

So the top few lines now look like this:

<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"; lang="en-GB" xml:lang="en-GB"> <head> 

Notice that I've included the html, head and body elements. These are optional in HTML 5 but required for polyglot documents.

There were a couple of other things to take care of though.

 
No comment yet.
Scooped by Mickael Ruau
Scoop.it!

HTML5 / HTML 4.01 / xHTML, Balise et doctype

HTML5 / HTML 4.01 / xHTML, Balise et doctype | Bonnes Pratiques Web & Cloud | Scoop.it
Le tableau ci-dessous répertorie tous les éléments du HTML 4.01, du XHTML et du HTML5 et leur validité en fonction du doctype choisis.
Mickael Ruau's insight:

Ce tableau répond à la question "Quelles balises sont autorisées suivant la version de html?"

No comment yet.
Scooped by Mickael Ruau
Scoop.it!

HTML5 - Wikipédia

HTML5 - Wikipédia

HTML5 (HyperText Markup Language 5 ) est la prochaine révision majeure d' HTML ( format de données conçu pour représenter les pages web). Cette version est en développement en 2013. HTML5 spécifie deux syntaxes d'un modèle abstrait défini en termes de DOM : HTML5 et XHTML5.

Mickael Ruau's insight:
Il est intéressant de comparer la version française et la version anglaise, car elles apportent des informations complémentaires.

 

XHTML5

VF : "Pour les documents XHTML5, l'auteur doit spécifier l'encodage dans le prologue XML, mais aussi le type de contenu : « application/xhtml+xml ». La globalité de la page doit être conforme à la syntaxe XML. De par le caractère extensible du langage XML, il est possible d'ajouter d'autres balises (exemple : <mabalise></mabalise>) ; une telle extension nécessite de déclarer les espace de noms correspondants, sans quoi la page sera en erreur et le navigateur pourrait ne pas être capable de l'afficher. C’est le mode le plus strict qui impose d'avoir une syntaxe quasi parfaite.


<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="fr" lang="fr" dir="ltr"> <head> <title>Exemple</title> </head> <body> <!-- Contenu de la page respectant la syntaxe XML. --> </body> </html>

"


VO : "XHTML5 is the XML serialization of HTML5. XML documents must be served with an XML Internet media type (often confused with MIME type) such as application/xhtml+xml orapplication/xml.[51] 

 

XHTML5 requires XML's strict, well-formed syntax. The choice between HTML5 and XHTML5 boils down to the choice of a MIME/content type: the media type one chooses determines what type of document should be used.[52] In XHTML5, the HTML5 doctype html is optional and may simply be omitted.[53] HTML that has been written to conform to both the HTML and XHTML specifications—and which will therefore produce the same DOM tree whether parsed as HTML or XML—is termed "polyglot markup".[54]

Error handling

HTML5 is designed so that old browsers can safely ignore new HTML5 constructs.[citation needed] In contrast to HTML 4.01, the HTML5 specification gives detailed rules for lexing and parsing, with the intent that different compliant browsers will produce the same result in the case of incorrect syntax.[55] Although HTML5 now defines a consistent behavior for "tag soup" documents, those documents are not regarded as conforming to the HTML5 standard.[55]"

No comment yet.
Scooped by Mickael Ruau
Scoop.it!

HTML5 Reference

HTML5 Reference | Bonnes Pratiques Web & Cloud | Scoop.it
Mickael Ruau's insight:
3.6 Polyglot Documents

A polyglot HTML document is a document that conforms to both the HTML and XHTML syntactic requirements, and which can be processed as either by browsers, depending on the MIME type used. This works by using a common subset of the syntax that is shared by both HTML and XHTML.

 

Polyglot documents are useful to create for situations where a document is intended to be served as either HTML or XHTML, depending on the support in particular browsers, or when it is not known at the time of creation, which MIME type the document will ultimately be served as.

 

In order to successfully create and maintain polyglot documents, authors need to be familiar with both the similarities and differences between the two syntaxes. This includes not only syntactic differences, but also differences in the way stylesheets, and scripts are handled, and the way in which character encodings are detected.

 

This section will provide the details about each of these similarities and differences, and provide guidelines on the creation of polyglot documents.

Base this on the HTML vs. XHTML article.

No comment yet.
Scooped by Mickael Ruau
Scoop.it!

CSS Frame Generator

CSS Frame Generator | Bonnes Pratiques Web & Cloud | Scoop.it
Simple tool that will generate CSS frame out of your XHTML structure.
Mickael Ruau's insight:

This tool returns corresponding CSS in a line-by-line way indented with spaces to reflect XHTML structure - each selector and all of its properties and values in one line. This may be a bit strange for you at the beginning, but if you get used to it you'll find it much better.

 

It's essential to use a predefined properties order, such as this one:

 

display position z-index visibility overflow float clear list-style width height margin padding border backgroundcolor font line-height text-* letter-spacing word-spacing word-wrap white-space vertical-align outline cursor

 

 
No comment yet.