Vam's Notes

Just notes. But notes for everything.

导航

XHTML

XHTML Syntax
  • XHTML is a stricter and cleaner version of HTML.
  • In addition, you should start NOW to write your HTML code in lowercase letters, and NEVER skip ending tags (like </p>).
  • XHTML Elements Must Be Properly Nested
  • XHTML Elements Must Always Be Closed
  • Empty Elements Must Also Be Closed
  • XHTML Elements Must Be In Lower Case
  • XHTML Documents Must Have One Root Element
  • Attribute Values Must Be Quoted
  • Attribute Minimization Is Forbidden

    HTML XHTML 
    compact compact="compact"
    checked checked="checked"
    declare declare="declare"
    readonly readonly="readonly"
    disabled disabled="disabled"
    selected selected="selected"
    defer defer="defer"
    ismap ismap="ismap"
    nohref nohref="nohref"
    noshade noshade="noshade"
    nowrap nowrap="nowrap"
    multiple multiple="multiple"
    noresize noresize="noresize"
  • The id Attribute Replaces The name Attribute

    To make your XHTML compatible with today's browsers, you should add an extra space before the "/" symbol.
  • Mandatory XHTML Elements

    All XHTML documents must have a DOCTYPE declaration. The html, head and body elements must be present, and the title must be present inside the head element.
    This is a minimum XHTML document template:
    <!DOCTYPE Doctype goes here>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Title goes here</title>
    </head><body>
    </body></html>

    Note: The DOCTYPE declaration is not a part of the XHTML document itself. It is not an XHTML element, and it should not have a closing tag.

    Note: The xmlns attribute inside the <html> tag is required in XHTML. However, the validator on w3.org does not complain when this attribute is missing in an XHTML document. This is because "xmlns=http://www.w3.org/1999/xhtml" is a fixed value and will be added to the <html> tag even if you do not include it.


XHTML DTD

The XHTML standard defines three Document Type Definitions.

  • <!DOCTYPE> Is Mandatory
  • An XHTML document consists of three main parts:
    • the DOCTYPE
    • the Head
    • the Body
  • This is a simple (minimal) XHTML document:
    <!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
    >
    <html>
    <head>
    <title>simple document</title>
    </head>
    <body>
    <p>a simple paragraph</p>
    </body>
    </html>
  • The 3 Document Type Definitions
    • DTD specifies the syntax of a web page in SGML.
    • DTD is used by SGML applications, such as HTML, to specify rules that apply to the markup of documents of a particular type, including a set of element and entity declarations.
    • XHTML is specified in an SGML document type definition or 'DTD'.
    • An XHTML DTD describes in precise, computer-readable language, the allowed syntax and grammar of XHTML markup.

  • There are currently 3 XHTML document types:
    • STRICT
    • TRANSITIONAL
    • FRAMESET
XHTML Modularization
  • With modular XHTML, designers can:
    • Choose the elements to be supported by a device using standard XHTML building blocks
    • Add extensions to XHTML, using XML, without breaking the XHTML standard
    • Simplify XHTML for devices like hand held computers, mobile phones, TV, and home appliances
    • Extend XHTML for complex applications by adding new XML functionality (like MathML, SVG, Voice and Multimedia)
    • Define XHTML profiles like XHTML Basic (a subset of XHTML for mobile devices)

  • XHTML Modules

    W3C has split the definition of XHTML into 28 modules:

    Module name Description
    Applet Module Defines the deprecated* applet element
    Base Module Defines the base element
    Basic Forms Module Defines the basic forms elements
    Basic Tables Module Defines the basic table elements
    Bi-directional Text Module Defines the bdo element
    Client Image Map Module Defines browser side image map elements
    Edit Module Defines the editing elements del and ins
    Forms Module Defines all elements used in forms
    Frames Module Defines the frameset elements
    Hypertext Module Defines the a element
    Iframe Module Defines the iframe element
    Image Module Defines the img element
    Intrinsic Events Module Defines event attributes like onblur and onchange
    Legacy Module Defines deprecated* elements and attributes
    Link Module Defines the link element
    List Module Defines the list elements ol, li, ul, dd, dt, and dl
    Metainformation Module Defines the meta element
    Name Identification Module Defines the deprecated* name attribute
    Object Module Defines the object and param elements
    Presentation Module Defines presentation elements like b and i
    Scripting Module Defines the script and noscript elements
    Server Image Map Module Defines server side image map elements
    Structure Module Defines the elements html, head, title and body
    Style Attribute Module Defines the style attribute
    Style Sheet Module Defines the style element
    Tables Module Defines the elements used in tables
    Target Module Defines the target attribute
    Text Module Defines text container elements like p and h1

    * Deprecated elements should not be used in XHTML.

Link:

HTML 4.01 / XHTML 1.0 Reference

posted on 2007-06-27 11:27  Vam  阅读(215)  评论(0编辑  收藏  举报