1 / 10

Understanding DOCTYPE and Compliance Issues in HTML and XHTML

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.

jhumphrey
Download Presentation

Understanding DOCTYPE and Compliance Issues in HTML and XHTML

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Internet 9/20/11 XHTML 1.0 CIS 228

  2. “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.

  3. 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">

  4. 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)

  5. 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

  6. 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

  7. 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)

  8. XML Related Specifications • XML Namespaces • XML Base • XML Information Set • XPath • XQuery • XSLT • XSL Formatting Objects • XML Signature • XML Encryption

  9. 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”

  10. 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" >

More Related