Tuesday, 8 September 2015

Html And XHtml

Html XHtml:

Xhtml is Html written as XML.

XHTML:

XHtml stands for EXtensible Hyper Text Markup Language.It is almost identical to Html.XHtml is stricter than html.It is Html defined as XML application.XHtml is supported bu all browsers.

Why XHTML Is Used?

On internet many pages contain bad Html.
This html code works fine even if it does not follow html rules in most browsers.

Now a days market consists of many different browser technologies.Some browsers work on mobiles, some works on computers or other devices. Smaller devices like mobiles lack power to interpret bad markup.
XML is markup language where documents must be marked up correctly be well formed.
By combining strengths  of Html and XML,Xhmtl was developed.
XHtml is Html redesigned as XML.

Important Differences From Html:

Document Structure :

1)XHtml doctype is mandatory
2)xmlns attribute in <html> is also mandatory
3)<html> , <head> , <body> and <title>are mandatory

XHtml Elements:

1)Elements of XHtml must be properly nested
2)Elements of Xhtml must be always closed
3)Elements of XHtml must be in lowercase
4)Documents of XHtml must have one root element

XHtml Attributes:

1)Names of attribute must be in lower case
2)Values Of Attribute must be quoted
3)Attribute minimization is foridden

Is Mandatory <Doctype...>:

XHtml document must have XHtml doctype declaration.
<html> , <head> , <title> and <body> elements must be presnt and xmlns attribute in <html> must specify xnl namespace for document.

Example:


Elements Of XHtml Must Be Properly Nested:

Some elements in Html can be improperly nested within each other like this

All elements must be properly nested within each other in XHtml like this

Elements In XHtml Must Be Closed:

It is wrong

It is correct

Empty Elements Also Be Closed:

It is wrong

It is correct

Elements In XHtml Should Be In Lower Case:

It is wrong

It is correct

Attribute Names In Xhtml Must be In Lower Case:

It is wrong

It is correct

Attribute Values Must Be Quoted:

It is wrong

it is correct

Attribute Mininmization Forbidden:

Wrong

Correct

Wrong

Correct

How to Convert From Html to Xhtml:

1)Add XHtml <!Doctype> to first line of every page
2)Add xmlns attribute to html element of every page
3)Change all element names to lowercase
4)Close all empty elements
5)Change all attribute names to lowercase
6)Quote all attribute values

No comments:

Post a Comment