Upload
morgan-walton
View
222
Download
2
Embed Size (px)
Citation preview
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>
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.
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>
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.
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">
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>
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.
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.
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">
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").