Sie sind auf Seite 1von 24

HTML, XHTML and X

M. Tanzil Furqon, S.Kom Click to edit Master subtitle style Ilmu Komputer Brawijaya

5/8/12

HTML vs XHTML
v

XHTML elements must be properly nested


In HTML, some elements can be improperly nested within each other, like this: <b><i>This text is bold and italic</b></i>

In XHTML, all elements must be properly nested within each other, like this: <b><i>This text is bold and italic</i></b>

XHTML elements must always be closed

5/8/12

This is wrong: <p>This is a paragraph <p>This is another paragraph This is correct: <p>This is a paragraph</p> <p>This is another paragraph</p>

HTML vs XHTML (cont)


v

XHTML elements must be in lowercase

This is wrong: <BODY> <P>This is a paragraph</P> </BODY> This is correct: <body> <p>This is a paragraph</p> </body>

XHTML documents must have one root element

The basic document structure is: <html> <head> ... </head> 5/8/12 <body> ... </body>

HTML vs XHTML (cont)


v

Attribute values must be quoted


This is wrong: <table width=100%> This is correct: <table width="100%"> This is wrong: <input checked> <input readonly> <input disabled> <option selected> <frame noresize> This is correct: <input checked="checked" /> <input readonly="readonly" /> <input disabled="disabled" /> <option selected="selected" />

Attribute minimization is forbidden

5/8/12

HTML vs XHTML (cont)


v

The id attribute replaces the name attribute

This is wrong: <img src="picture.gif" name="pic1" /> This is correct: <img src="picture.gif" id="pic1" />

Note: To interoperate with older browsers for a while, you should use both name and id, with identical attribute values, like this: <img src="picture.gif" id="pic1" name="pic1" /> v IMPORTANT Compatibility Note: To make your XHTML compatible with today's browsers, you should add an extra space before the "/" 5/8/12
v

HTML vs XHTML (cont)


v

The XHTML DTD defines mandatory elements An XHTML document consists of three main parts:

the DOCTYPE declaration the <head> section the <body> section

<!DOCTYPE Doctype goes here> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Title goes here</title> 5/8/12

This is an XHTML document with a minimum of required tags:

HTML vs XHTML (cont)


v

Note: The DOCTYPE declaration is not a part of the XHTML document itself. It is not an XHTML element. Note: The xmlns attribute in <html>, specifies the xml namespace for a document, and is required in XHTML documents. However, the HTML validator at w3.org does not complain when the xmlns attribute is missing. This is because the namespace "xmlns=http://www.w3.org/1999/xhtml" is default, and will be added to the <html> tag even if you do not include it.

5/8/12

Document Type Definitions (DTD)


v

A DTD specifies the syntax of a web page in SGML DTDs are used by SGML applications, such as HTML, to specify rules for documents of a particular type, including a set of elements and entity declarations An XHTML DTD describes in precise, computerreadable language, the allowed syntax of XHTML markup There are three XHTML DTDs:

5/8/12

STRICT TRANSITIONAL

XHTML 1.0 Strict


Use the strict DOCTYPE when you want really clean markup, free of presentational clutter. Use it together with CSS. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1strict.dtd">
v

5/8/12

XHTML 1.0 Transitional


Use the transitional DOCTYPE when you want to still use HTML's presentational features. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1transitional.dtd">
v

5/8/12

XHTML 1.0 Frameset


Use the frameset DOCTYPE when you want to use HTML frames. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1frameset.dtd">
v

5/8/12

XHTML 1.0 DTD

5/8/12

XHTML 1.0 DTD (cont)

5/8/12

XHTML 1.0 DTD (cont)

5/8/12

XHTML 1.0 DTD (cont)

S=Strict, T=Transitional, and F=Frameset

5/8/12

XHTML Modules
v

For some purposes XHTML is too large and complex, and for other purposes it's too simple. With modular XHTML, designers can:

Choose the elements to be supported by a device Simplify XHTML for small devices Extend XHTML for complex applications by adding new XML functionality (like MathML, SVG, Voice and Multimedia) Define XHTML profiles like XHTML Basic (a subset of XHTML for mobile devices)

5/8/12

XHTML 28 modules

5/8/12

XML vs HTML
v v

XML was designed to transport and store data. HTML was designed to display data.

5/8/12

XML vs HTML (cont)


v

The Difference Between XML and HTML


XML is not a replacement for HTML. XML and HTML were designed with different goals:

XML was designed to transport and store data, with focus on what data is. HTML was designed to display data, with focus on how data looks.

HTML is about displaying information, while XML is about carrying information.

5/8/12

XML Does not DO Anything


Maybe it is a little hard to understand, but XML does not DO anything. XML was created to structure, store, and transport information. v The following example is a note to Tove from Jani, stored as XML: <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> v It 5/8/12 is just pure information wrapped in tags.
v

XML is Not a Replacement for HTML


XML is a complement to HTML. v It is important to understand that XML is not a replacement for HTML. In most web applications, XML is used to transport data, while HTML is used to format and display the data. v My best description of XML is this: XML is a software- and hardwareindependent tool for carrying information. (http://www.w3schools.com/xml/xml_whatis.asp)
v

5/8/12

HTML, XHTML and XML


XHTML derived from XML and HTML where XML derives from SGML (Standardized General Markup Language) v XHTML is a mark-up language v XML and SGML is a meta language (A language is what's used to build other languages) v Markup languages created with XML include XHTML, MathML (for mathematics), VoiceXML (for speech), SMIL (the Synchronized Multimedia Integration Language for multimedia presentations), CML (Chemical Markup Language for chemistry) and XBRL 5/8/12
v

Why the need for XHTML?


v

5/8/12

The XHTML family is designed to accommodate extensions (in XML) through XHTML modules and techniques for developing new XHTMLconforming modules. These modules will permit the combination of existing and new feature sets when developing content and when designing new user agents. Alternate ways of accessing the Internet are constantly being introduced. With XHTML it will be possible to develop XHTML-conforming content that is usable by any XHTMLconforming user agent.

Source

5/8/12

Das könnte Ihnen auch gefallen