Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

What's the difference between html and xhtml?

user-image
Question ajoutée par Faisal Ali , Web Developer , Bayt.com - Jordan
Date de publication: 2016/12/31
Haytham Hashim
par Haytham Hashim , Digital Marketing Manager , WeMake

HTML

  • Start tags are not required for every element.
  • End tags are not required for every element.
  • Only void elements such as br, img, and link may be “self-closed” with />.
  • Tags and attributes are case-insensitive.
  • Attributes do not need to be quoted.
  • Some attributes may be empty (such as checked and disabled).
  • Special characters, or entities, do not have to be escaped.
  • The document must include an HTML5 DOCTYPE.

XHTML

  • All elements must have a start tag.
  • Non-void elements with a start tag must have an end tag (p and li, for example).
  • Any element may be “self-closed” using />.
  • Tags and attributes are case sensitive, typically lowercase.
  • Attribute values must be enclosed in quotes.
  • Empty attributes are forbidden (checked must instead be checked="checked" or checked="true").
  • Special characters must be escaped using character entities.
  • XHTML documents must be well-formed

Irshad Mouhammad Dusmahomed
par Irshad Mouhammad Dusmahomed , Freelance Php developer , Freelance

Hmm, XHTML is a stricter version html and are almost the same except some differences. XHTML is there to prevent "bad" html coding.

Some things like <!DOCTYPE is mandatory in XHTML. also it enforces some other rules such as lower case on attribute names.

 

Both describe the structure of web pages using mark up. Well mainly in a xml format. 

Amir Khan
par Amir Khan , LAMP/PHP Web Programmer , GTA Web Developers

Following example demonstrate the difference b/w HTML and XHTML:

HTML example

-----------------

<img alt="Loren ipsum" src="/images/abc.jpg">

<p lang="fr">Loren ipsum.</p>

<p><cite class="title">Loren ipsum</cite></p>

====================================

XHTML example

-----------------

<img alt="Loren ipsum" src="/images/abc.jpg" />

<p xml:lang="fr">Loren ipsum.</p>

<p><cite class="title">Loren ipsum</cite></p>

=======================

Notice the difference: <p xml:lang="fr"> in XHTML

Utilisateur supprimé
par Utilisateur supprimé

Comparing HTML(Hypertext Markup Language) and XHTML(Extensible HTML) could be like comparing identical twins.since there are only a few minor point.

 

Implementation Point of view differents is;

1. Tag minimization

HTML does not require all elements to have closing tags.

Of course, in XML this document would be malformed because the <p> element is not closed.

2. Case sensitivity.

HTML is case insensitive, but XHTML (as all XML) is case sensitive.

3. Empty Element Syntax

The syntax for empty elements is different.

 

In HTML, empty element syntax is <elementName>

 

In XHTML empty element syntax is <elementName />

4. Attribute Values

Attribute values must be enclosed by single or double quotes.

 

In HTML, this is allowed: <meta name=keywords>

 

In XHTML it must read <meta name="keywords" /> or <meta name='keywords' />

5. Boolean attributes

Minimized attributes are now allowed in XHTML/XML

 

In HTML, a boolean attribute could be expressed <p nowrap>

 

In XHTML, is must read <p nowrap="nowrap">

6. Fragment Identifiers

Many existing HTML clients don't support the use of ID-type attributes in this way, so identical values may be supplied for both of these attributes to ensure maximum forward and backward compatibility:

 

<a id="target1" name="target1">...</a><br/> <br/>

Utilisateur supprimé
par Utilisateur supprimé

Le HTML est un langage qui évolue. Plusieurs versions se sont succédées : HTML 1, HTML 2, HTML 3 puis HTML 4.

Le XHTML 1 (Extensible Hypertext Markup Language) est apparu peu après le HTML 4. Il s'agit en fait d'une reformulation plus rigoureuse du HTML. Seule la syntaxe change, les fonctionnalités sont les mêmes.

Le choix est fait dans ce cours d'utiliser le XHTML pour la création de pages Web.Ceci pour les raisons suivantes :

  • C'est la version la plus récente et celle qui a le plus d'avenir.
  • Si sa syntaxe est plus précise, elle est également plus logique, et donc plus facile à comprendre.
  • Notons que les différences de syntaxe entre HTML et XHTML sont minimes et qu'il est facile de passer de l'un à l'autre.

More Questions Like This