XHTML http www w 3 schools comxhtml What

  • Slides: 14
Download presentation
XHTML http: //www. w 3 schools. com/xhtml/

XHTML http: //www. w 3 schools. com/xhtml/

What is XHTML? n XHTML stands for Extensible Hypertext Markup Language n n XHTML

What is XHTML? n XHTML stands for Extensible Hypertext Markup Language n n XHTML is aimed to replace HTML XHTML is almost identical to HTML 4. 01 XHTML is a stricter and cleaner version of HTML XML (Extensible Markup Language) is a markup language designed for describing data n n XHTML is HTML redefined as an XML application XHTML is a “bridge” between HTML and XML 2

The problem with HTML n n n HTML started out as a way of

The problem with HTML n n n HTML started out as a way of describing the structure of documents, with tags to indicate headers, paragraphs, and the like Because people wanted to control the appearance of documents, HTML acquired tags to control fonts, alignment, etc. The result is a markup language that does both, but isn’t very good at either 3

HTML vs. XML looks a lot like HTML, but-HTML uses a fixed set of

HTML vs. XML looks a lot like HTML, but-HTML uses a fixed set of tags With XML you make up your own tags (and define what they mean in a separate document) HTML is designed to display XML is designed to describe data to humans data to computers Browsers are very tolerant of errors in HTML XML documents must be wellformed (syntactically correct) All browsers can display HTML All modern browsers display XML, but in various ways 4

From HTML to XHTML, I n XHTML elements must be properly nested <b><i>bold and

From HTML to XHTML, I n XHTML elements must be properly nested <b><i>bold and italic</b></i> is wrong n XHTML documents must be well-formed <html> <head>. . . </head> <body>. . . </body> </html> n n Tag names must be in lowercase All XHTML elements must be closed n n If an HTML tag is not a container, close it like this: , <hr />, <img src="smile. gif" /> Note: Some older browsers require a space before the / 5

From HTML to XHTML, II n Attribute names must also be in lower case

From HTML to XHTML, II n Attribute names must also be in lower case n n Attribute values must be quoted n n Example: <table width="100%"> Attribute minimization is forbidden n n Example: <table width="100%"> Example: <frame noresize="noresize">, cannot be abbreviated to <frame noresize> The id attribute replaces the name attribute n n n Wrong: <img src="picture. gif" name="picture 1" /> Right: <img src="picture. gif" id="picture 1" /> Best: <img src="picture. gif" name="picture 1" id="picture 1" /> 6

SGML and DTDs n n SGML stands for “Standard Generalized Markup Language” HTML, XML

SGML and DTDs n n SGML stands for “Standard Generalized Markup Language” HTML, XML and many other markup languages are defined in SGML A DTD, or “Document Type Definition” describes the syntax to use for the current document There are three different DTDs for XHTML--you can pick the one you want n n These DTDs are public and on the web You must start your XHTML document with a reference to one of these DTDs 7

DOCTYPE declaration, I n Every XHTML document must begin with one of the DOCTYPE

DOCTYPE declaration, I n Every XHTML document must begin with one of the DOCTYPE declarations (DTDs): n n <!DOCTYPE html PUBLIC "-//W 3 C//DTD XHTML 1. 0 Strict//EN" "http: //www. w 3. org/TR/xhtml 1/DTD/xhtml 1 -strict. dtd"> <!DOCTYPE html PUBLIC "-//W 3 C//DTD XHTML 1. 0 Transitional//EN" "http: //www. w 3. org/TR/xhtml 1/DTD/xhtml 1 -transitional. dtd"> <!DOCTYPE html PUBLIC "-//W 3 C//DTD XHTML 1. 0 Frameset//EN" "http: //www. w 3. org/TR/xhtml 1/DTD/xhtml 1 -frameset. dtd"> <!DOCTYPE html PUBLIC "-//W 3 C//DTD XHTML 1. 1//EN” "http: //www. w 3. org/TR/xhtml 11/DTD/xhtml 11. dtd"> n (Essentially the same as XHTML 1. 0 Strict) 8

DOCTYPE declaration, II n The main DTDs are as follows: n 1. 0 Strict

DOCTYPE declaration, II n The main DTDs are as follows: n 1. 0 Strict n n n 1. 0 Transitional n n n Use with standard HTML and/or with CSS Allows deprecated HTML elements 1. 0 Frameset n n Use for really clean markup, with no display information (no font, color, or size information) Use with CSS (Cascading Style Sheets) if you want to define how the document should look Use if your document uses HTML frames 1. 1 n Like 1. 0 Strict, but with added support for Chinese 9

An XHTML Example n <!DOCTYPE html PUBLIC "-//W 3 C//DTD XHTML 1. 0 Strict//EN"

An XHTML Example n <!DOCTYPE html PUBLIC "-//W 3 C//DTD XHTML 1. 0 Strict//EN" "http: //www. w 3. org/TR/xhtml 1/DTD/xhtml 1 -strict. dtd"> <html xmlns="http: //www. w 3. org/1999/xhtml" xml: lang="en"> <head> <title>A simple document</title> </head> <body> <p>A simple paragraph. </p> </body> </html> 10

Extension n A file containing an HTML page should have the extension. html According

Extension n A file containing an HTML page should have the extension. html According to W 3 C, an XHTML page should have the extension. xhtml However. . . n n I have had trouble getting Java. Script to work on pages with this extension I recommend sticking with. html, at least for now 11

Tools n n Dave Raggett's HTML TIDY, http: //tidy. sourceforge. net/, is a free

Tools n n Dave Raggett's HTML TIDY, http: //tidy. sourceforge. net/, is a free UNIX tool for checking and cleaning up HTML pages The W 3 C HTML Validation Tool http: //validator. w 3. org/ is an HTML form for checking (but not fixing) HTML and XHTML documents 12

Vocabulary n SGML: Standard Generalized Markup Language n n HTML: Hypertext Markup Language XHTML:

Vocabulary n SGML: Standard Generalized Markup Language n n HTML: Hypertext Markup Language XHTML: e. Xtensible Hypertext Markup Language XML: e. Xtensible Markup Language DTD: Document Type Definition 13

The End 14

The End 14