xp tutorial 9 1 working with xhtml. xp sgml 2 standard generalized markup language (sgml) a standard...

32
XP Tutorial 9 1 Working with XHTML

Upload: prudence-henderson

Post on 01-Jan-2016

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XP

Tutorial 9

1

Working with XHTML

Page 2: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPSGML

2

Standard Generalized Markup Language (SGML) A standard for specifying markup languages.Large, complex standard capable of specifying many

different types of markup languages.Device and System Independent

MML: Math Markup Language is a markup language:

Rendering

Code

Page 3: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPSGML HTMLSGML XML XHTML

3

SGML RULES

HTML

XML RULES

XHTMLInconsistent, browser support difficult

Consistent rules for efficient browser support

Many other markup

languages

Other XML languages

Page 4: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XP

HTML and XHTML

4

HTML (Hypertext Markup Language)1998: Version 4.0 most current (4.01 not officially

implemented)Can be applied inconsistentlyBrowser code must be complex, inefficient, to

handle inconsistencies.

XHTML (Extensible Hypertext Markup Language)2002: Version 1.1 most current (1.0 still extensively

used)Strict standards for consistency.Browser code can be efficient, run on small devices.

Page 5: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XP

XHTML Versions

5

Page 6: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPAbout XHTML Documents1. An XHTML document that correctly follows the

syntax rules is called a well-formed document.

2. Because XHTML documents conform to XML rules, enter an “XML declaration” (XML Prolog) as the first line of the file.

3. A special document called a “DTD” (document type definition) is used to specify correct content and structure.

4. A special attribute called the “xhtml namespace” is inserted in the opening <html> tag.

5. If the document is well-formed and also has correct content and structure, it is called a valid document.6

Page 7: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPAn XHTML document that correctly follows the syntax rules is called a well-formed document.

7 “attribute minimization” not allowed

Page 8: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPBecause XHTML documents conform to XML rules, enter an “XML declaration” (XML Prolog) as the first line of the file.

8

For XHTML documents, use the declaration:

<?xml version=“1.0” encoding=“UTF-8”?>

XML Version number

character encoding

Page 9: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPA special document called a “DTD” (document type definition) is used to specify correct content and structure.

9

• The DOCTYPE declaration, which tells which DTD is associated with the document, is the second line of the file, after the XML prolog statement. It is used to tell the browser what version of the markup language the page is written in.

<!DOCTYPE root type “id” “url”>

Page 10: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPDocument Type Definition (“DTD”)

10

- The DTD specifies the rules for a valid document

- There are 3 types of the XHTML DTD- Transitional: allows many of the older HTML

features but not framesets- Frameset: allows many of the older HTML

features including framesets- Strict: does not allow any presentational features

or deprecated HTML elements and attributes. Does not support frames or inline frames. Used when there is a need to strictly conform to the latest standards

- There are also definitions for straight HTML documents.dtd_list.txt This link can also be found on my Data for Labs page

Page 11: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPDocument Elements that are not valid under the Strict DTD

11

Elements not allowed under the strict DTD are:

appletbasefontcenterdirfontframeframeset

iframeisindexmenunoframessstrikeu

http://www.w3schools.com/tags/tag_dir.asp List and description of all tags

Page 12: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPAttributes under the Strict DTD

12

Some attributes are restricted, while others are required in XHTML

Restricted (prohibited) attributes under the strict XHTML DTD are shown on page 536 of the textbook.

Required attributes under the strict XHTML DTD are shown on page 537 of the textbook.

Page 13: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPAttributes Prohibited under the Strict DTD

13

Page 14: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPAttributes Required under the Strict DTD

14

Page 15: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPA special attribute called the “xhtml namespace” is inserted in the opening <html> tag.

15

• To set XHTML as the default namespace for a document, add the xmlns attribute to the html element with the following value:

<html xmlns=“http://www.w3.org/1999/xhtml”>

• A namespace is any string of characters that uniquely identifies the set of elements and attributes belonging to the particular language.

dtd_list.txt This link can also be found on my Data for Labs page

Page 16: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPIf the document is well-formed and also has correct content and structure, it is called a valid document

16

This is an example of an xhtml document that correctly conforms to the “Strict” DTD

XHTML can be checked for validation at http://validator.w3.org

Page 17: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPValidation of XHTML

17

Click “Validate by File Upload”Click “Browse”

Page 18: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPValidation of XHTML

18

Select the file you want to validateClick “Check”

Page 19: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPValidation of XHTML

19

If it is valid, you get “…successfully checked. . .”

Page 20: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPValidation of XHTML

20

This is an example of an xhtml document that does not conform to the “Strict” DTD

(Can you see the error?)

Page 21: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPValidation of XHTML

21

If it is not valid you get “Error found . . . “

“bgcolor” is not allowed under the strict DTD

http://validator.w3.org

Page 22: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPValidation of XHTML

22

To validate under a different version of the DTD, change the DOCTYPE declaration

Page 23: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPUsing Style Sheets and XHTML

23

• Style sheets sometimes contain characters that could cause problems for the browser:

• A CDATA section marks a block of text so that the browser will not treat text as html code:

> means any img element that is a direct descendent of a p element.

• If your code contains characters like > , it’s best to use an external style sheet instead of an embedded one.

Page 24: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPFixing XHTML Validation Errors

24

• Some examples of things you might need to do to make an xhtml file pass the validator check:

Convert body element attributes to styles in a style sheet.

Page 25: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPFixing XHTML Validation Errors

25

• Some examples of things you might need to do to make an xhtml file pass the validator check:

Correct errors for one or two-sided elements not properly closed or one-sided tags not terminated.

Page 26: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPFixing XHTML Validation Errors

26

• Some examples of things you might need to do to make an xhtml file pass the validator check:

Use the float style to align inline images.

180-img-styles.htm

Page 27: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPFixing XHTML Validation Errors

27

• Some examples of things you might need to do to make an xhtml file pass the validator check:

Remove/replace deprecated elements or attributes.

185-img-styles.htm

Page 28: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPFixing XHTML Validation Errors

28

• Some examples of things you might need to do to make an xhtml file pass the validator check:

Remove/replace deprecated elements or attributes.

Page 29: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPFixing XHTML Validation Errors

29

• Some examples of things you might need to do to make an xhtml file pass the validator check:

Remove/replace deprecated elements or attributes.

Page 30: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPFixing XHTML Validation Errors

30

• Some examples of things you might need to do to make an xhtml file pass the validator check:

Replace formatting done with <b> and or <font> by styles.

Page 31: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPFixing XHTML Validation Errors

31

• Some examples of things you might need to do to make an xhtml file pass the validator check:

Replace prohibited

attributes such as name with a valid attribute such as

id

Page 32: XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard

XPThe End

32