iNET Interactive - Online Advertising Agency
          
   Home    Authors    About    Login    Contact Us
   Search:   
Advanced Search     
  Articles

  ASP (26)
  ASP.NET (19)
  C and C++ (4)
  CFML (2)
  CGI and Perl (16)
  Flash (2)
  Java (7)
  JavaScript (28)
  PHP (92)
  MySQL (13)
  MSSQL (3)
  HTML (35)
  SEO (9)
  Visual Basic (12)
  CSS (13)
  SSI (5)
  XML (12)
  C# (14)

  Developer News

August 7, 2008
Wish XML a happy birthday
About
 
August 7, 2008
Poll: How important is SEO to your overal website strategy?
About
 
August 7, 2008
How to Create a Search Feature with PHP and MySQL
WebReference.com
 
August 7, 2008
1 comment
.net
 
August 6, 2008
10 New SEO Reports
About
 
August 5, 2008
Array Creator
EarthWeb.com
 
Courtesy of moreover.com
 
Want to receive new articles via e-mail? Click here!
/Home /HTML /XHTML

XHTML, the future of HTML 

  Views:    2707
  Votes:    2
by Diego Botello 11/30/03 Rating: 

Synopsis:

This article will show you the basics of XHTML and how to convert your HTML pages to XHTML.
Pages: 
The Article

HTML is a very succesful language, a large proportion of the web is written with it,

but it has came to a point where further development becomes difficult. The problem

with HTML is that it´s lousily typed, so to show it on a browser, the code of the browser

needs to be more powerful to be able to show the page properly. This represents a

problem to all the portable devices like handheld pc´s which have far less processing

power, not being able to show HTML pages. To solve this the W3Consortium developed

the XHTML standard.

 

XHTML means Extensible Hypertext Markup Language. If you alredy know HMTL, then

XHTML will be easy for you. You have to remember a few things to code your pages on XHTML:

 

  1. Tag and attribute names must be written in lowercase:

    In HMTL you can write your tags either in lowercase or uppercase,

    and even combine both on the same document.

     

    <CENTER><H1>This is centered text</H1></CENTER>


     

    In XHTML you have to write all tags and attribute names in lowercase

     

    <center><h1>This is centered text</h1></center>

     

  2. Elements must be nested properly

    In HTML it was posible to nest in this way:

     

    <i>This is <b>some text</i></b>

     

    In XHTML you have to next the elements in the proper order

     

    <i>This is <b>some text</b></i>

     

  3. All elements have to be closed

    Some HTML elements like paragraph didn´t need to be closed on HTML

     

    <p> This is a paragraph

    <p> This is another paragraph

     

    In XHTML you have to close all elements

     

    <p> This is a XHTML paragraph </p>

    <p> This is another XHTML paragraph </p>

     

    There are some elements in HMTL that do not have a closing tag,

    those elements are called empty elements. Empty elements also need

    to be closed. To close them you add a forward slash / before the end bracket >.

    To keep compatibility with current browsers you have to left a space

    between the element text and the forward slash. In HTML we have:

     

    This line ends with a break <br>

    <img src="myimage.jpg">

     

    And in XHTML

     

    This line ends with a break <br />

    <img src="myimage.jpg" />

     

  4. All attribute values must be quoted and cannot be minimized

    In HTML we have this

     

    <ul compact>

     

    In XHTML you have to make it like this

     

    <ul compact="compact">

     

  5. The name atribute is replaced with id

    In HTML some tags elements (a, applet, frame, iframe, img, and map) have a name attibute,

     

    <img src="mypicture.jpg" name="mypicture"/>

     

    In XHTML you need to change that for the id attribute

     

    <img src="mypicture.jpg" id="mypicture" />
    
    For the code to be compatible with current browsers you have to use both attributes
    
    <img src="mypicture.jpg" id="mypicture" name="mypicture" />
     
  6. Mandatory elements

In XHTML is mandatory to include the following elements: html, head, body and title.

 

The DOCTYPE declaration is also mandatory.

There are three valid XHTML document types

 

  • STRICT

This declaration is used when you want to use CSS.

You have to use this DOCTYPE declaration

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
  • TRANSITIONAL

This declaration is used when you want to support browsers that can´t use CSS.

You have to use this DOCTYPE declaration

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
  • FRAMESET

This declaration is used when you want to use frames on your pages.

You have to use this DOCTYPE declaration

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
 

Conclusion

As you can see is very easy to change your current page to be XHTML compliant.

 

 

Pages: 



 
  Sponsors