100 likes | 115 Views
Learn about the importance of DOCTYPE declarations in web pages and compliance issues in HTML and XHTML. Ensure your pages adhere to the correct standards for consistent display across browsers.
E N D
The Internet 9/20/11 XHTML 1.0 CIS 228
“Quirks” Mode Today, all browsers support standards Compliant pages are displayed similarly There are multiple standards HTML 4, HTML 4.01, XHTML 1.0, XHTML 1.1, … Browsers need to know which standard a page adheres to Browsers still need to support old web pages Each browser does this differently (and slowly) To avoid “quirks” mode DOCTYPE announces the standard your page uses Make sure your page obeys that standard.
DOCTYPE On the top line of your html file Only a handfull to choose from Spelling (including capitalization) must be identical HTML 4.01 (transitional) <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> HTML 4.01 (strict) <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> XHTML 1.0 (strict) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
HTML 4.01 Compliance Issues Images need an alt attribute Specify a character encoding <meta http-equiv=”Content-Type” content=“text/html; charset=utf-8”> Don't leave off end (or start) tag html element required Containing head and body elements (and nothing else) title element required in head element Only block elements nest directly in body or blockquote Block elements cannot be in p or inline elements a elements cannot contain other a elements List elements (ol and ul) only contain list items (li)
XML Timeline • 1960's – GML • 1988 – SGML standard • 1991 – HTML • 1994 – World Wide Web Consortium (W3C) • 1996 – XML work begins • 1998 – XML 1.0 W3C recommendation • 1999 – XML Namespaces W3C recommendation • 2001 – XML Schema W3C recommendation
XML • Replacement for SGML (HTML-like syntax) • Mechanism for specifying markup languages • Sub-language documents must • Be well-formed XML documents • Be valid wrt a document type definition • Document type definition defines the sublanguage • XHTML is HTML as a XML sub-language • XML parsers recognize XML documents • XML applications process XML documents
eXtensible Markup Language • Markup language (“well-formed”) • Simple rules / rigidly enforced • Matching start & end tags required and must nest properly • Empty tags end “/>” • No special characters (<, >, &, “, ') in content • Meta Markup language(“valid”) • Schema (grammar) specifies document type • Schema indicated by URL in DOCTYPE • Different kinds of schema: • DTD (Document Type Definition) • XSD (XML Schema Definition)
XML Related Specifications • XML Namespaces • XML Base • XML Information Set • XPath • XQuery • XSLT • XSL Formatting Objects • XML Signature • XML Encryption
XML Namespaces • Disambiguated element and attribute names • What do you mean by a “table”? • Namespace prefix • <furnature:table > • <html:table> • Namespace prefix definition • xmlns:prefix=”URL” (the URL is just a name) • Element inherit namespace definitions • Default namespace definition • xmlns=”URL”
XHTML 1.0 Strict • Well-formed XML (empty elements end “ />”) • XML declaration (optional) • <?xml version="1.0" encoding="UTF-8" ?> • Document Type Declaration • <!DOCTYPE html • PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" • "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > • Root element • <html xmlns="http://www.w3.org/1999/xhtml" • xml:lang="en" lang="en" >