lesson 4. an xhtml document consists of three main parts: the doctype; the head the body

14
Lesson 4

Upload: logan-chase

Post on 13-Jan-2016

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lesson 4. An XHTML document consists of three main parts: The DOCTYPE; The Head The Body

Lesson 4

Page 2: Lesson 4. An XHTML document consists of three main parts: The DOCTYPE; The Head The Body

An XHTML document consists of three main parts:

• The DOCTYPE;

• The Head

• The Body.

Page 3: Lesson 4. An XHTML document consists of three main parts: The DOCTYPE; The Head The Body

Strict<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Strict: Strict follows the most stringent rules of XHTML. Only current elements, attributes, and character entities are allowed in documents written in this type. Elements such as font or center, that were deprecated in HTML 4.0, are not allowed. Obsolete elements are also not allowed.

In summary it defines the DTD that we are using.

Use this when you want really clean markup, free of presentational clutter. Use this together with Cascading Style Sheets.

Page 4: Lesson 4. An XHTML document consists of three main parts: The DOCTYPE; The Head The Body

Transitional

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Transitional: A transitional XHTML 1.0 document is more lenient, allowing the author to use deprecated as well as current methods. You can use font or center, or any other deprecated markup in a transitional document -- so long as the document itself is properly marked as such. No obsolete elements should be used.

Use this when you need to take advantage of HTML's presentational features because many of your readers don't have the latest browsers that understand Cascading Style Sheets.

Page 5: Lesson 4. An XHTML document consists of three main parts: The DOCTYPE; The Head The Body

Frameset

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

Frameset: The frameset DTD is reserved only for frameset documents. A frameset document conforming to this DTD can use either strict or transitional markup.

Use this when you want to use HTML Frames to partition the browser window into two or more frames.

To check that you have written a valid XHTML document with a correct DTD,  you can link your XHTML page to a validator.

xmlnsDeclares in the <html> tag the XHTML name space and language attributes.

Page 6: Lesson 4. An XHTML document consists of three main parts: The DOCTYPE; The Head The Body

All XHTML documents must have a DOCTYPE declaration. The html,

head and body elements must be present, and the title must be

present inside the head element.

This is a minimum XHTML document template:

<!DOCTYPE Doctype goes here>

<html>

<head>

<title>Title goes here</title>

</head>

<body>

Body text goes here

</body>

</html>

Note: The DOCTYPE declaration is not a part of the XHTML

document itself. It is not an XHTML element, and it should not

have a closing tag.

Page 7: Lesson 4. An XHTML document consists of three main parts: The DOCTYPE; The Head The Body

Here are the main things to remember when writing XHTML:

• Must have a DOCTYPE declaration

• All XHTML tags are lower case

• Close all tags (even empty elements)

• Attribute values must be quoted

• Minimization is forbidden

• The id attribute replaces the name attribute

• Documents must conform to XML rules

Page 8: Lesson 4. An XHTML document consists of three main parts: The DOCTYPE; The Head The Body

ReviewTrue / False

All XHTML documents must have a DOCTYPE declaration. The document must include the usual html, head, title, and body elements.

TRUE Example of DOCTYPE:

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

Page 9: Lesson 4. An XHTML document consists of three main parts: The DOCTYPE; The Head The Body

Review

What is wrong with this

<A HREF="xhtml/xhtml_tutorial.html" TARGET="_BLANK"> XHTML Tutorial</A>

All XHTML tags are lower case

Right <a href="xhtml/xhtml_tutorial.html" target="_blank"> XHTML Tutorial</a>

Page 10: Lesson 4. An XHTML document consists of three main parts: The DOCTYPE; The Head The Body

Review

<b><i> This text is bold and italic</b> </i>

Documents must conform to XML rules

<b><i> This text is bold and italic</i></b>

Page 11: Lesson 4. An XHTML document consists of three main parts: The DOCTYPE; The Head The Body

What is wrong with this

<img src=“pict/xhtml_lesson.gif">

Close all tags (even empty elements)

<img src="pict/xhtml_lesson.gif" />

Page 12: Lesson 4. An XHTML document consists of three main parts: The DOCTYPE; The Head The Body

Review

What is wrong with this

<img src="pict/xhtml_lesson.gif" width=250 height=50

border=0 />

Attribute values must be quoted

<img src="pict/xhtml_lesson.gif" width="250" height="50"

border="0" />

Page 13: Lesson 4. An XHTML document consists of three main parts: The DOCTYPE; The Head The Body

Review

<option selected>

Minimization is forbidden

<option selected="selected">

Page 14: Lesson 4. An XHTML document consists of three main parts: The DOCTYPE; The Head The Body

Review

<img src="pict/xhtml_lesson.gif" name="xhtml_lesson">

The id attribute replaces the name attribute

<img src="pict/xhtml_lesson.gif" id="xhtml_lesson">