11
XHTML and Forms Review – Page 1 CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: Review XHTML and Forms

XHTML and Forms Review – Page 1CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: Review XHTML and Forms

Embed Size (px)

Citation preview

Page 1: XHTML and Forms Review – Page 1CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: Review XHTML and Forms

XHTML and Forms Review – Page 1CSCI 2910 – Client/Server-Side Programming

CSCI 2910 Client/Server-Side Programming

Topic: Review XHTML and Forms

Page 2: XHTML and Forms Review – Page 1CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: Review XHTML and Forms

XHTML and Forms Review – Page 2CSCI 2910 – Client/Server-Side Programming

Difference Between HTML and XHTML

The purpose of HTML tags is to turn on and off formatting. Because of this, it isn't vital to observe rules such as nesting. For example, in HTML, the following code is okay:

<p>This paragraph would <i>not be

<b>legal</i> in XHTML.</p></b>

Page 3: XHTML and Forms Review – Page 1CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: Review XHTML and Forms

XHTML and Forms Review – Page 3CSCI 2910 – Client/Server-Side Programming

Difference Between HTML & XHTML (continued)

• XHTML is an application of HTML that follows the rules of XML

• The purpose of XML tags is to contain data. If the following document were not properly nested, there would trouble trying to identify the data.

Page 4: XHTML and Forms Review – Page 1CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: Review XHTML and Forms

XHTML and Forms Review – Page 4CSCI 2910 – Client/Server-Side Programming

XML Example<classroom>

<teacher><name>Dave Tarnoff</name><userid>tarnoff</userid>

</teacher><student>

<name>Abby Betsy Catcher</name><userid>zabc123</userid>

</student><student>

<name>David Ebenezer Fletcher</name><userid>zdef456</userid>

</student><student>

<name>George Harris Izod</name><userid>zghi789</userid>

</student></classroom>

Page 5: XHTML and Forms Review – Page 1CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: Review XHTML and Forms

XHTML and Forms Review – Page 5CSCI 2910 – Client/Server-Side Programming

Benefits of XHTML over HTML

• Easy to introduce new elements. (HTML typically only added new elements when IE/Netscape competition resulted in a new tag.) XHTML can be extended beyond predefined elements.

• More rigorous syntax makes for simpler browser code which is good for products such as cell phones.

• Better portability across different platforms.

Page 6: XHTML and Forms Review – Page 1CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: Review XHTML and Forms

XHTML and Forms Review – Page 6CSCI 2910 – Client/Server-Side Programming

Differences between HTML & XHTML

• Documents must be well formed– Must have opening and closing tags for container tags– New format for in-line tags– Must be properly nested

• Element and attribute names must be in lower case

• Attribute values must always be in quotations• Attribute minimization is not allowed, e.g.,

NORESIZE must be noresize="noresize"• Identify elements using both name and id

attributes, e.g., <input type="text" name="userid" id="userid">

Page 7: XHTML and Forms Review – Page 1CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: Review XHTML and Forms

XHTML and Forms Review – Page 7CSCI 2910 – Client/Server-Side Programming

Template for XHTML document

<?xml version="1.0" encoding="ISO-8859-1"?>

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

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head><title>Simple XHTML Document</title></head><body><h1>Hello, World!</h1></body></html>

Page 8: XHTML and Forms Review – Page 1CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: Review XHTML and Forms

XHTML and Forms Review – Page 8CSCI 2910 – Client/Server-Side Programming

XML Declaration

• <?xml version="1.0" encoding="ISO-8859-1"?>• The XML declaration defines the XML version

and the character encoding that should be used to interpret the document.

• Computers store all information as 1's and 0's. There are different ways to represent characters using these 1's and 0's. The character encoding used by a document is the method to use when converting the 1's and 0's into characters.

Page 9: XHTML and Forms Review – Page 1CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: Review XHTML and Forms

XHTML and Forms Review – Page 9CSCI 2910 – Client/Server-Side Programming

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

• The W3C has defined a document type definition (DTD) to be, "...a collection of declarations that, as a collection, defines the legal structure, elements, and attributes that are available for use in a document that complies to the DTD."

• The DOCTYPE tag identifies which DTD the browser is supposed to use when displaying the XHTML document.

Page 10: XHTML and Forms Review – Page 1CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: Review XHTML and Forms

XHTML and Forms Review – Page 10CSCI 2910 – Client/Server-Side Programming

Three DTD Types• Strict DTD: Adheres exactly to XHTML standard.

• Transitional DTD: Uses HTML rather than CSS to format page. Allows use of deprecated elements. Allows for widest audience.

• Frameset DTD: Used when document is partitioned into 2 or more frames.

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

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

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

Page 11: XHTML and Forms Review – Page 1CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: Review XHTML and Forms

XHTML and Forms Review – Page 11CSCI 2910 – Client/Server-Side Programming

XML Namespace and Language• <html xmlns="http://www.w3.org/1999/xhtml"

xml:lang="en" lang="en">

• The W3C has defined an XML namespace as, "a collection of names, identified by a URI (uniform resource identifier) reference, which is used in XML documents as element types and attribute names."

• The html tag is used to define the language for the XHTML document (lang="en") and for the XML used (xml:lang="en").