12.07.2015 Views

HTML ---> XHTML - eyelearn

HTML ---> XHTML - eyelearn

HTML ---> XHTML - eyelearn

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>HTML</strong> ---> X<strong>HTML</strong>A Brief Introduction to X<strong>HTML</strong>Extensible HyperText Markup Language (X<strong>HTML</strong>) is a reformulation of <strong>HTML</strong> 4.0 tomake it XML based. This tutorial deals with the changes to be made to convert <strong>HTML</strong>documents to valid X<strong>HTML</strong>. The article is prepared with a view to help and guideyou through the conversion process.The W3C, which is the organisation that co-ordinates standardisation of Webprotocols, has defined three types of X<strong>HTML</strong> documents. This is based on the XMLDocument Type Definition (DTD) that is used by the document. The X<strong>HTML</strong> DTDsare:1. Strict: Used when the X<strong>HTML</strong> document is devoid of all formatting tagslike and Cascading Style Sheets (CSS) are used for controlling allpresentation aspects.2. Transitional: This X<strong>HTML</strong> DTD allows use of presentation tags in thedocument. This is a safer mode since most of our pages contain manypresentation elements.3. Frameset: Used for X<strong>HTML</strong> documents that describes frames.01The document type declarationfor transitional X<strong>HTML</strong> documents is:This should be the next line after the processing instruction.The declarations for the other X<strong>HTML</strong> DTDs are:XML requires that there must be one and only one root element for a document.Hence, in X<strong>HTML</strong>, all tags should be enclosed within the tag, ie., should be the root element for the document.The starting tag should be modified to include namespace information. Themodification is as:Attribute xmlns is the XML namespace with which we associate the X<strong>HTML</strong>document. The value of the attribute lang is the code for the language of thedocument as specified in RFC1766.


tags in X<strong>HTML</strong>• All X<strong>HTML</strong> tag elements should be in lower case.That means and are wrong. They should be rewrittenas and respectively.02• All X<strong>HTML</strong> tags should have their end tags.In <strong>HTML</strong> it is common for paragraphs to have only the starting tag.In X<strong>HTML</strong> this is not allowed. You need to end a paragraph with the tag.Example: Hello is wrong; it should be written as Hello.• Empty X<strong>HTML</strong> tags should be ended with /> instead of >.The commonly used empty tags in X<strong>HTML</strong> are:• : for meta information (contained in the head section)• : used to specify the base URI and also the target framefor hyperlinks (contained in the head section)• : used to specify a base font for the document.Note that attribute ‘size’ is mandatory• : parameters for applets and objects.• : to specify external stylesheets and other references.• : to include images. Attributes ‘src’ for the source URIand ‘alt’ for alternate text are mandatory.• : used for forced line break.• : for horizontal rules.• : used inside image maps. Attribute ‘alt’ is mandatory.• : used inside forms for input form elements like buttons,textboxes, textareas, checkboxes and radio buttons.Example: is wrong;it should be rewritten as . is wrong;it should be • Proper nesting of tags is compulsory in X<strong>HTML</strong>.Example: This is bold italics is wrong.It should be rewritten as This is bold italics.Rules for X<strong>HTML</strong> Attributes• All X<strong>HTML</strong> attribute names should be in lower case.Example: Width=”100” and WIDTH=”100” are wrong;only width=”100” is correct.Similarly onMouseOut=”javascript:myFunction();” is wrong;it should be rewritten as onmouseout=”javascript:myFunction();”.• All attribute-value pairs should be quoted.Example: width=100 is wrong; it should be width=”100” or width=’100’.• The name attribute is deprecated and will be removed in a future version ofX<strong>HTML</strong> and the id attribute will take its place. So, for <strong>HTML</strong> tags that need thename attribute, an id attribute should also be specified with the same value as thatfor name.Example: becomes


• <strong>HTML</strong> supports certain attributes which have no values. Examples are noshadewhich appears in the tag.X<strong>HTML</strong> does not allow such empty or compact attributes. The compactattributes generally found in <strong>HTML</strong> are compact, nowrap, ismap, declare,noshade, checked, disabled, readonly, multiple, selected, noresizeand defer.They should always have a value. In X<strong>HTML</strong> this is done by giving the attributename itself as the value!Example: noshade becomes noshade=”noshade”checked becomes checked=”checked”03• All & (ampersand) characters in the source code have to be replaced with <strong>&amp</strong>;,which is the equivalent character entity code. This change should be done in allattribute values and URIs.Example: Bee&Nee will result in an error if you try to validate it; It should bewritten as Bee<strong>&amp</strong>;Nee.Go is wrong;it should be coded as Go.X<strong>HTML</strong> Tables• For tag, attribute height is not supported in X<strong>HTML</strong> 1.0. Only the width issupported. The tag does support the height attribute.• The , and the tag does not support the attribute backgroundwhich is used to specify a background image for the table or the cell. Backgroundimages will have to be specified either using the style attribute or using externalstylesheet. The attribute bgcolor for background color is however supported bythese tags.X<strong>HTML</strong> Images• The alt attribute is mandatory. This value of this attribute will be the text that hasto be shown in older browsers, text-only browsers (like lynx), and in place of theimage when it is not available.Note that is an empty tag.Example: X<strong>HTML</strong> and Javascript• The type attribute is mandatory for all tags. This value of type istext/javascript for Javascript.• The use of external scripts is recommended.Example:


• If you are using internal scripts, enclose it within the starting tag . This will mark it as unparsed character data.Otherwise characters like & and < will be treated as start of character entities(like &nbsp;) and tags (like ) respectively.Example for X<strong>HTML</strong> Javascript:04X<strong>HTML</strong> and Stylesheets• The type attribute is mandatory for tag. The value of type is text/cssfor stylesheets.• The use of external stylesheets is recommended.Example: • Enclose internal style definitions within the starting tag to mark it as unparsed character data.Example:Otherwise the & and < characters will be treated as start of character entities(like &nbsp;) and tags (like ) respectively.Element Prohibitions in X<strong>HTML</strong>The W3C recommendation also prohibits certain X<strong>HTML</strong> elements from containingsome elements. Those are given below:• cannot contain other elements.• cannot contain the , , , , , or elements.• cannot contain the , , , ,, , , , or elements.• cannot contain other elements.• cannot contain other elements.


X<strong>HTML</strong> Resources on the Web• The W3C Pages on XMLThe W3C are the people who work for the formulation and standardisationof Web technologies including X<strong>HTML</strong>. They are the best place to go.05• Download the X<strong>HTML</strong> 1.0 Transitional DTDThe DTD (Document Type Definition) is used to define an XML application. X<strong>HTML</strong>is also a XML application and all the rules can be found in this well documentedDTD.• <strong>HTML</strong>-TidyWritten by Dave Reggett, this tool can will accept any [bloated or rotten] <strong>HTML</strong> andmake it to adhere to standards. It can also be used to accelerate conversion of<strong>HTML</strong> to XML or X<strong>HTML</strong>.• Chami’s <strong>HTML</strong>-KitAn excellent <strong>HTML</strong> editor (not visual, but supports previewing) which supportsX<strong>HTML</strong>. It supports the <strong>HTML</strong>-Tidy as a plugin. Recommended.• The W3C Online Validator for X<strong>HTML</strong>X<strong>HTML</strong> documents can be validated online with this W3C Service. Recommended.• RFC1766This RFC defines the two-letter tags for the Identification of Languages.article: beeandnee.com © 2000-2002. Bejoy Alex Jaisonhttp://www22.brinkster.com/beeandnee

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!