PR-HTML40-971107 HTML 4.0 Specification W3C Proposed Recommendation 7-Nov-1997 This version: http://www.w3.org/TR/PR-html40-971107/ Latest version: http://www.w3.org/TR/PR-html40/ Previous version: http://www.w3.org/TR/WD-html40-970917/ Editors: Dave Raggett Arnaud Le Hors Ian Jacobs Abstract This specification defines the HyperText Markup Language (HTML), version 4.0, the publishing language of the World Wide Web. In addition to the text, multimedia, and hyperlink features of the previous versions of HTML, HTML 4.0 supports more multimedia options, scripting languages, style sheets, better printing facilities, and documents that are more accessible to users with disabilities. HTML 4.0 also takes great strides towards the internationalization of documents, with the goal of making the Web truly World Wide. HTML 4.0 is an SGML application conforming to International Standard ISO 8879 -- Standard Generalized Markup Language [ISO8879]). As an SGML application, the syntax of conforming HTML 4.0 documents is defined by the combination of the SGML declaration and the document type definition (DTD). This specification defines the intended interpretation of HTML 4.0 elements and adds syntax constraints that may not be expressed by the DTD alone. Status of this document This is a stable document derived from the 17 September working draft of the HTML 4.0 specification. This document has been produced as part of the W3C HTML Activity. The publication of this document does not imply endorsement by the Consortium's staff or Member organizations. On 7 November, this document enters a period of review by the Members of the World Wide Web Consortium. Details of this review will be distributed to the representatives of each W3C Member organization. The review period will end on 5 December. Within 14 days after that date, the document's disposition will be announced: it may become a W3C Recommendation (possibly with minor changes), it may revert to Working Draft status, or it may be dropped as a W3C work item. Most of this document represents technology tested by multiple implememntations. It includes a small number of features that have not had the benefit of extensive implementation experience. Nonetheless, the experience of the Working Group members with analogous features in other domains has resulted in consensus that these features belong in this specification. The Working Group expects to resolve minor technical issues during the review phase and communicate its results to the W3C Director. A list of current W3C Proposed Recommendations and Working Drafts can be found at: http://www.w3.org/TR. It is proposed that HTML 4.0 be recommended for new documents and applications rather than HTML 3.2, specified in http://www.w3.org/TR/REC-html32. Available formats The HTML 4.0 W3C Proposed Recommendation is also available in the following formats: a plain text file: http://www.w3.org/TR/PR-html40-971107/html40.txt (691Kb), HTML as a gzip'ed tar file: http://www.w3.org/TR/PR-html40-971107/html40.tgz (293Kb), HTML as a zip file (this is a '.zip' file not an '.exe'): http://www.w3.org/TR/PR-html40-971107/html40.zip (324Kb), as well as a postscript file (thanks to html2ps written by Jan Kärrman): http://www.w3.org/TR/PR-html40-971107/html40.ps (3.5Mb, 339 pages), and a PDF file: http://www.w3.org/TR/PR-html40-971107/html40.pdf (2Mb) file. In case of a discrepancy between electronic and printed forms of the specification, the electronic version is considered the definitive version. Available languages The English version of this specification is the only normative version. However, for translations in other languages see http://www.w3.org/TR/PR-html40-971107/translations.html. Comments Please send detailed comments on this document to www-html-editor@w3.org. We cannot guarantee a personal response but we will try when it is appropriate. Public discussion on HTML features takes place on www-html@w3.org. Table of Contents 1. About the HTML 4.0 Specification 1. How the specification is organized 2. Document conventions 1. Elements and attributes 2. Notes and examples 3. Acknowledgments 2. Introduction to HTML 4.0 1. What is the World Wide Web? 1. Introduction to URLs 2. Fragment identifiers 3. Relative URLs 2. What is HTML? 1. A brief history of HTML 3. HTML 4.0 1. Internationalization 2. Accessibility 3. Tables 4. Compound documents 5. Style sheets 6. Scripting 7. Printing 4. Designing documents with HTML 4.0 1. Separate structure and presentation 2. Consider universal accessibility to the Web 3. Help user agents with incremental rendering 3. On SGML and HTML 1. Introduction to SGML 2. SGML constructs used in HTML 1. Elements 2. Attributes 3. Entities 4. Comments 3. How to read the HTML DTD 1. DTD Comments 2. Parameter entity definitions 3. Element declarations + Content model definitions 4. Attribute definitions + DTD entities in attribute definitions + Boolean attributes 4. Conformance: requirements and recommendations 1. Definitions 2. SGML 3. The text/html content type 5. HTML Document Representation - Character sets, character encodings, and entities 1. The Document Character Set 2. Character encodings 1. Choosing an encoding + Notes on specific encodings 2. Specifying the character encoding 3. Character references 4. Undisplayable characters 6. Basic HTML data types - Character data, colors, lengths, URLs, content types, etc. 1. Case information 2. SGML basic types 3. Text strings 4. URLs 5. Colors 1. Notes on using colors 6. Lengths 7. Content types (MIME types) 8. Language codes 9. Character encodings 10. Single characters 11. Dates and times 12. Link types 13. Media descriptors 14. Script data 15. Frame target names 7. The global structure of an HTML document - The HEAD and BODY of a document 1. Introduction to the structure of an HTML document 2. HTML version information 3. The HTML element 4. The document head 1. HEAD element 2. The TITLE element 3. The title attribute 4. Meta data + Specifying meta data + The META element + Meta data profiles 5. The document body 1. The BODY element 2. Element identifiers: the id and class attributes 3. Block-level and inline elements 4. Grouping elements: the DIV and SPAN elements 5. Headings: The H1, H2, H3, H4, H5, H6 elements 6. The ADDRESS element 8. Language information and text direction - International considerations for text 1. Specifying the language of content: the lang attribute 1. Language codes 2. Inheritance of language codes 3. Interpretation of language codes 2. Specifying the direction of text and tables: the dir attribute 1. Introduction to the bidirectional algorithm 2. Inheritance of text direction information 3. Setting the direction of embedded text 4. Overriding the bidirectional algorithm: the BDO element 5. Character entities for directionality and joining control 6. The effect of style sheets on bidirectionality 9. Text - Paragraphs, Lines, and Phrases 1. White space 2. Structured text 1. Phrase elements: EM, STRONG, DFN, CODE, SAMP, KBD, VAR, CITE, and ABBR 2. Quotations: The BLOCKQUOTE and Q elements 3. Subscripts and superscripts: the SUB and SUP elements 3. Lines and Paragraphs 1. Paragraphs: the P element 2. Controlling line breaks + Forcing a line break: the BR element + Prohibiting a line break 3. Hyphenation 4. Preformatted text: The PRE element 5. Visual rendering of paragraphs 4. Marking document changes: The INS and DEL elements 10. Lists - Unordered, Ordered, and Definition Lists 1. Introduction to lists 2. Unordered lists (UL), ordered lists (OL), and list items (LI) 3. Definition lists: the DL, DT, and DD elements 1. Lists formatted by visual user agents 4. The DIR and MENU elements 11. Tables 1. Introduction to tables 2. Elements for constructing tables 1. The TABLE element + Table directionality 2. Table Captions: The CAPTION element 3. Row groups: the THEAD, TFOOT, and TBODY elements 4. Column groups: the COLGROUP and COL elements + The COLGROUP element + The COL element + Calculating the number of columns in a table + Calculating the width of columns 5. Table rows: The TR element 6. Table cells: The TH and TD elements + Cells that span several rows or columns 3. Table formatting by visual user agents 1. Borders and rules 2. Horizontal and vertical alignment + Inheritance of alignment specifications 3. Cell margins 4. Table rendering by non-visual user agents 1. Associating header information with data cells 2. Categorizing cells 3. Algorithm to find heading information 5. Sample table 12. Links - Hypertext and Media-Independent Links 1. Introduction to links and anchors 1. Visiting a linked resource 2. Other link relationships 3. Specifying anchors and links 4. Link titles 5. Internationalization and links 2. The A element 1. Syntax of anchor names 2. Nested links are illegal 3. Anchors with the id attribute 4. Unavailable and unidentifiable resources 3. Document relationships: the LINK element 1. Forward and reverse links 2. Links and external style sheets 3. Links and search engines 4. Path information: the BASE element 1. Resolving relative URLs 13. Objects, Images, and Applets 1. Introduction to objects, images, and applets 2. Including an image: the IMG element 3. Generic inclusion: the OBJECT element 1. Rules for rendering objects 2. Object initialization: the PARAM element 3. Global naming schemes for objects 4. Object declarations and instantiations 4. Including an applet: the APPLET element 5. Including HTML in another HTML document 6. Image maps 1. Client-side image maps + Alternate access to image maps + Client-side image maps with MAP, AREA, and usemap + Client-side image maps for OBJECT with shapes 2. Server-side image maps 7. Visual presentation of images, objects, and applets 1. Width and height 2. White space around images and objects 3. Borders 4. Alignment 8. How to specify alternate text 14. Style Sheets - Controlling the presentation of an HTML document 1. Introduction to style sheets 2. Adding style to HTML 1. Setting the default style sheet language 2. Inline style information 3. Header style information: the STYLE element 4. Media types 5. External style sheets 6. Setting the default named style 7. Media-dependent cascades 3. Inheritance and cascading 4. Hiding the content of style elements from non-conforming user agents 5. Specifying style through HTTP headers 15. Alignment, font styles, and horizontal rules 1. Formatting 1. Background color 2. Alignment 3. Floating objects + Float an object + Float text around an object 2. Fonts 1. Font style elements: the TT, I, B, BIG, SMALL, STRIKE, S, and U elements 2. Font modifier elements: FONT and BASEFONT 3. Rules: the HR element 16. Frames - Multi-view presentation of documents 1. Introduction to frames 2. Layout of frames 1. The FRAMESET element + Rows and columns + Nested frame sets 2. The FRAME element + Setting the initial document in a frame + Decorating a frame 3. Specifying target frame information 1. Setting the default target for links 2. Target semantics 4. Alternate content 1. The NOFRAMES element 5. Inline frames: the IFRAME element 17. Forms - User-input Forms: Text Fields, Buttons, Menus, and more 1. Introduction to forms 2. The FORM element 3. Controls 1. The INPUT element + Input types + The ISINDEX element 2. The BUTTON element 3. The SELECT, OPTGROUP, and OPTION elements 4. The TEXTAREA element 4. Labels 1. The LABEL element 5. Adding structure to forms: the FIELDSET and LEGEND elements 6. Giving focus to an element 1. Tabbing navigation 2. Access keys 7. Disabled and read-only elements 1. Disabled elements 2. Read-only elements 8. Form submission 1. Processing form data + Step one: Build a form data set + Step two: Encode the form data set + Step three: Submit the encoded form data set 2. Which control values are submitted 18. Scripts - Animated Documents and Smart Forms 1. Introduction to scripts 2. Designing documents for user agents that support scripting 1. The SCRIPT element 2. Specifying the scripting language + The default scripting language + Local declaration of a scripting language + References to HTML elements from a script 3. Intrinsic events + Parsing of intrinsic event scripts 4. Dynamic modification of documents 3. Designing documents for user agents that don't support scripting 1. The NOSCRIPT element 2. Commenting out scripts 19. SGML reference information for HTML - Formal definition of HTML and validation 1. Document Validation 2. Sample SGML catalog 20. SGML Declaration of HTML 4.0 1. SGML Declaration 21. Document Type Definition 22. Transitional Document Type Definition 23. Frameset Document Type Definition 24. Character entity references in HTML 4.0 1. Introduction to character entity references 2. Character entity references for ISO 8859-1 characters 1. The list of characters 3. Character entity references for symbols, mathematical symbols, and Greek letters 1. The list of characters 4. Character entity references for markup-significant and internationalization characters 1. The list of characters A. Changes between HTML 3.2 and HTML 4.0 1. Changes to elements 1. New elements 2. Deprecated elements 3. Obsolete elements 2. Changes to Tables 3. Changes to Forms 4. Changes for internationalization B. Performance, Implementation, and Design Notes 1. Representing non-ASCII characters in URLs 2. SGML implementation notes 1. Line breaks 2. SGML features with limited support 3. Boolean attributes 4. Marked Sections 5. Processing Instructions 6. Shorthand markup 3. Notes on helping search engines index your Web site 1. Search robots + The robots.txt file + Robots and the META element 4. Notes on tables 1. Design rationale + Dynamic reformatting + Incremental display + Structure and presentation + Row and column groups + Accessibility 2. Recommended Layout Algorithms + Fixed Layout Algorithm + Autolayout Algorithm 5. Notes on forms 1. Incremental display 2. Future projects 6. Notes on scripting 1. Reserved syntax for future script macros + Current Practice for Script Macros 7. Notes on frames 1. Frame target algorithm 8. Notes on accessibility 1. Generating alternate text 9. Notes on security * References 1. Normative references 2. Informative references * Index of Elements * Index of Attributes 1 About the HTML 4.0 Specification Contents 1. How the specification is organized 2. Document conventions 1. Elements and attributes 2. Notes and examples 3. Acknowledgments 1.1 How the specification is organized This specification is divided into the following sections: Sections 2 and 3: Introduction to HTML 4.0 The introduction describes HTMLs place in the scheme of the World Wide Web, provides a brief history of the development of HTML, highlights what can be done with HTML 4.0, and provides some design tips for developing good HTML habits. The brief SGML tutorial gives readers some understanding of HTML's relationship to SGML and gives summary information on how to read the HTML Document Type Declaration (DTD). Sections 4 - 24: HTML 4.0 reference manual The bulk of the reference manual consists of the HTML language reference, which defines all elements and attributes of the language. This document has been organized by topic rather than by the grammar of HTML. Topics are grouped into three categories: structure, presentation, and interactivity. Although it is not easy to divide HTML constructs perfectly into these three categories, the model reflects the designers' experience that separating a document's structure from its presentation produces more effective and maintainable documents. The language reference consists of the following information: o What characters may appear in an HTML document. o Basic data types of an HTML document. o Elements that govern the structure of an HTML document, including text, lists, tables, links, and included objects, images, and applets. o Elements that govern the presentation of an HTML document, including style sheets, fonts, colors, rules, and other visual presentation, and frames for multi-windowed presentations. o Elements that govern interactivity with an HTML document, including forms for user input and scripts for active documents. o The SGML formal definition of HTML: + The SGML declaration of HTML. + Three DTDs: strict, loose, and frameset. + The list of character references. Appendixes The first appendix contains information about changes from HTML 3.2 to help authors and implementors with the transition to HTML 4.0. The second appendix contains performance and implementation notes and is primarily intended to help implementors create user agents for HTML 4.0. References A list of normative and informative references. Indexes Two indexes give readers rapid access to the definition of all elements and attributes The indexes also summarize some key characteristics of each element and attribute. 1.2 Document conventions This document has been written with two types of readers in mind: authors and implementors. We hope the specification will provide authors with the tools they need to write efficient, attractive, and accessible documents, without over-exposing them to HTML's implementation details. Implementors, however, should find all they need to build conforming user agents. The specification may be approached in several ways: * Read from beginning to end. The specification begins with a general presentation of HTML and becomes more and more technical and specific towards the end. * Quick access to information. In order to get information about syntax and semantics as quickly as possible, the online version of the specification includes the following features: 1. Every reference to an element or attribute is linked to its definition in the specification. Each element or attribute is defined in only one location. 2. Every page will include links to the indexes, so you will never be more than two links away from finding the definition of an element or attribute. 3. The front pages of the three sections of the language reference manual extend the initial table of contents with more detail about each section. 1.2.1 Elements and attributes Element names are written in upper case letters (e.g., BODY). Attribute names are written in lower case letters (e.g., lang, onsubmit). Recall that in HTML, element and attribute names are case-insensitive; the convention is meant to encourage readability. Element and attribute names are marked within the source HTML for the specification and may be rendered specially by some user agents. Each attribute definition specifies the type of its value. If the type allows a small set of possible values, the definition lists the set of values, separated by a bar (|). After the type information, each attribute definition indicates the case-sensitivity of its values, between "[]" marks. See the section on case information for details. 1.2.2 Notes and examples Informative notes are emphasized to stand out from surrounding text and may be rendered specially by some user agents. All examples illustrating deprecated usage are marked as "DEPRECATED EXAMPLE". Deprecated examples also include recommended alternate solutions. All examples that illustrates illegal usage are clearly marked as "ILLEGAL EXAMPLE". Examples in the text conform to the strict document type declaration unless otherwise indicated or unless the example in question refers to elements or attributes only defined by the loose document type declaration or frameset document type declaration. For convenience, most of the examples in this specification do not begin with the document type declaration that is mandatory at the beginning of each HTML document. Examples and notes are marked within the source HTML for the specification and some user agents may render them specially. 1.3 Acknowledgments Thanks to everyone who has helped to author the working drafts that went into the HTML 4.0 specification, and all those who have sent suggestions and corrections. A particular thanks to T.V. Raman (Adobe) for his work on improving the accessibility of HTML forms for people with disabilities. The authors of this specification, the members of the W3C HTML Working Group, deserve much applause for their diligent review of this document, their constructive comments, and their hard work: John D. Burger (MITRE), Steve Byrne (JavaSoft), Martin J. Dürst (University of Zurich), Daniel Glazman (Electricité de France), Scott Isaacs (Microsoft), Murray Maloney (GRIF), Steven Pemberton (CWI), Jared Sorensen (Novell), Powell Smith (IBM), Robert Stevahn (HP), Ed Tecot (Microsoft), Jeffrey Veen (HotWired), Mike Wexler (Adobe), Misha Wolf (Reuters), and Lauren Wood (SoftQuad). Thank you Dan Connolly (W3C) for thoughtful input and guidance as chairman of the HTML working group. Thank you Sally Khudairi (W3C) for your indispensable work on the press release. Thanks to David M. Abrahamson and Roger Price for their careful reading of the specification and astute comments. Of particular help from the W3C at Sophia-Antipolis were Janet Bertot, Bert Bos, Stephane Boyera, Daniel Dardailler, Yves Lafon, Håkon Lie, Chris Lilley, and Colas Nahaboo from Bull. Lastly, thanks to Tim Berners-Lee without whom none of this would have been possible. 2 Introduction to HTML 4.0 Contents 1. What is the World Wide Web? 1. Introduction to URLs 2. Fragment identifiers 3. Relative URLs 2. What is HTML? 1. A brief history of HTML 3. HTML 4.0 1. Internationalization 2. Accessibility 3. Tables 4. Compound documents 5. Style sheets 6. Scripting 7. Printing 4. Designing documents with HTML 4.0 1. Separate structure and presentation 2. Consider universal accessibility to the Web 3. Help user agents with incremental rendering 2.1 What is the World Wide Web? The World Wide Web is a network of information resources. The Web relies on three mechanisms to make these resources readily available to the widest possible audience: 1. A uniform naming scheme for locating resources on the Web (e.g., URLs). 2. Protocols, for access to named resources over the Web (e.g., HTTP). 3. Hypertext, for easy navigation among resources (e.g., HTML). The ties between the three mechanisms are apparent throughout this specification. 2.1.1 Introduction to URLs Every resource available on the Web -- HTML document, image, video clip, program, etc. -- has an address that may be encoded by a Uniform Resource Locator, or "URL". URLs typically consist of three pieces: 1. The naming scheme of the mechanism used to access the resource. 2. The name of the machine hosting the resource. 3. The name of the resource itself, given as a path. Consider the URL that designates the current HTML specification: http://www.w3.org/TR/PR-html4/cover.html This URL may be read as follows: There is a document available via the HTTP protocol (see [RFC2068]), residing on the machine www.w3.org, accessible via the path "/TR/PR-html4/cover.html". Other schemes you may see in HTML documents include "mailto" for email and "ftp" for FTP. Here is another example of a URL. This one refers to a user's mailbox: ...this is text... For all comments, please send email to Joe Cool. 2.1.2 Fragment identifiers Some URLs refer to a location within a resource. This kind of URL ends with "#" followed by an anchor identifier (called the "fragment identifier"). For instance, here is a URL pointing to an anchor named section_2: http://somesite.com/html/top.html#section_2 2.1.3 Relative URLs A relative URL doesn't contain any naming scheme information. Its path generally refers to a resource on the same machine as the current document. Relative URLs may contain relative path components (".." means one level up in the hierarchy defined by the path), and may contain fragment identifiers. Relative URLs are resolved to full URLs using a base URL. As an example of relative URL resolution, assume we have the base URL "http://www.acme.com/support/intro.html". The relative URL in the following markup for a hypertext link: Suppliers would expand to the full URL "http://www.acme.com/support/suppliers.html", while the relative URL in the following markup for an image logo would expand to the full URL "http://www.acme.com/icons/logo.gif". In HTML, URLs play a role in these situations: * linking to another document or resource, (see the A and LINK elements). * linking to an external style sheet or script (see the LINK and SCRIPT elements). * images, objects and applets for inclusion in a page, (see the IMG, OBJECT, APPLET and INPUT elements). * image maps (see the MAP and AREA elements). * form submission (see FORM). * frames (see the FRAME and IFRAME elements). * citing an external reference (see the Q, BLOCKQUOTE, INS and DEL elements). * referring to metadata conventions describing a document (see the HEAD element). Please consult the section on the URL type for more information about URLs. 2.2 What is HTML? To publish information for global distribution, one needs a universally understood language, a kind of publishing mother tongue that all computers may potentially understand. The publishing language used by the World Wide Web is HTML (from HyperText Markup Language). HTML gives authors the means to: * Publish online documents with headings, text, tables, lists, photos, etc. * Retrieve online information via hypertext links, at the click of a button. * Design forms for conducting transactions with remote services, for use in searching for information, making reservations, ordering products, etc. * Include spread-sheets, video clips, sound clips, and other applications directly in their documents. 2.2.1 A brief history of HTML HTML was originally developed by Tim Berners-Lee while at CERN, and popularized by the Mosaic browser developed at NCSA. During the course of the 1990s it has blossomed with the explosive growth of the Web. During this time, HTML has been extended in a number of ways. The Web depends on Web page authors and vendors sharing the same conventions for HTML. This has motivated joint work on specifications for HTML. HTML 2.0 (November 1995, see [RFC1866]) was developed under the aegis of the Internet Engineering Task Force (IETF) to codify common practice in late 1994. HTML+ (1993) and [HTML30] (1995) proposed much richer versions of HTML. Despite never receiving consensus in standards discussions, these drafts led to the adoption of a range new features. The efforts of the World Wide Web Consortium's HTML working group to codify common practice in 1996 resulted in HTML 3.2 (January 1997, see [HTML32]). Changes from HTML 3.2 are summarized in Appendix A Most people agree that HTML documents should work well across different browsers and platforms. Achieving interoperability lowers costs to content providers since they must develop only one version of a document. If the effort is not made, there is much greater risk that the Web will devolve into a proprietary world of incompatible formats, ultimately reducing the Web's commercial potential for all participants. Each version of HTML has attempted to reflect greater consensus among industry players so that the investment made by content providers will not be wasted and that their documents will not become unreadable in a short period of time. HTML has been developed with the vision that all manner of devices should be able to use information on the Web: PCs with graphics displays of varying resolution and color depths, cellular telephones, hand held devices, devices for speech for output and input, computers with high or low bandwidth, and so on. 2.3 HTML 4.0 HTML 4.0 extends HTML with mechanisms for style sheets, scripting, frames, embedding objects, improved support for right to left and mixed direction text, richer tables, and enhancements to forms, offering improved accessibility for people with disabilities. 2.3.1 Internationalization This version of HTML has been designed with the help of experts in the field of internationalization, so that documents may be written in every language and be transported easily around the world. This has been accomplished by incorporating [RFC2070], which deals with the internationalization of HTML. One important step has been the adoption of the ISO/IEC:10646 standard (see [ISO10646]) as the document character set for HTML. This is the world's most inclusive standard dealing with issues of the representation of international characters, text direction, punctuation, and other world language issues. HTML now offers greater support for diverse human languages within a document. This allows for more effective indexing of documents for search engines, higher-quality typography, better text-to-speech conversion, correct hyphenation, etc. 2.3.2 Accessibility As the Web community grows and its members diversify in their abilities and skills, it is crucial that the underlying technologies be appropriate to their specific needs. HTML has been designed to make Web pages more accessible to those with physical limitations. HTML 4.0 developments in the area of accessibility include: * Encouraging the use of style sheets (rather than tables) to achieve layout effect. * Making it easier to provided alternate (textual and aural) descriptions of images for non-visual browsers. * Providing labels for form fields * Providing labeled hierarchical groupings for form fields. * Providing the ability to associate a longer text description with an HTML element. Authors who design pages with accessibility issues in mind will not only receive the blessings of the accessibility community, but will benefit in other ways as well: well-designed HTML documents that distinguish structure and presentation will adapt more easily to new technologies. 2.3.3 Tables The new table model in HTML is based on [RFC1942]. Authors now have greater control over structure and layout (e.g., column groups). The ability of designers to recommend column widths allows user agents to display table data incrementally (as it arrives) rather than waiting for the entire table before rendering. Note. At the time of writing, some HTML authoring tools rely extensively on tables for formatting, which may easily cause accessibility problems. 2.3.4 Compound documents HTML now offers a standard mechanism for embedding generic media objects and applications in HTML documents. The OBJECT element (together with its more specific ancestor elements IMG and APPLET) provides a mechanism for including images, video, sound, mathematics, specialized applications, and other objects in a document. It also allows authors to specify a hierarchy of alternate renderings for user agents that don't support a specific rendering. 2.3.5 Style sheets Style sheets simplify HTML markup and largely relieve HTML of the responsibilities of presentation. They give both authors and users control over the presentation of documents -- font information, alignment, colors, etc. Style information can be specified for specific elements or groups of elements either within an HTML document or in separate style sheets. The mechanism for associating a style sheet with a document is independent of the style sheet language. Before the advent of style sheets, authors had limited control over rendering. HTML 3.2 included a number of attributes and elements offering control over alignment, font size, and text color. Authors also exploited tables and images as a means for laying out pages. The relatively long time it takes for users to upgrade their browsers means that these features will continue to be used for some time. However, since style sheets offer more powerful presentation mechanisms, the World Wide Web Consortium will eventually phase out many of HTML's presentation elements and attributes. Throughout the specification elements and attributes at risk are marked as "deprecated". They are usually accompanied by examples of how to achieve the same effects with other elements or style sheets. This specification includes three Document Type Definitions (DTDs) that may be used to validate HTML 4.0 documents. One for use with framesets, a loose DTD for transitional documents and a strict DTD that excludes presentation elements and attributes. 2.3.6 Scripting Through scripts, authors may create "smart forms" that react as users fill them out. Scripting allows designers to create dynamic Web pages, and to use HTML as a means to build networked applications. The mechanisms provided to associate HTML with scripts are independent of particular scripting languages. 2.3.7 Printing Sometimes, authors will want to make it easy for users to print more than just the current document. When documents form part of a larger work, the relationships between them can be described using the HTML LINK element or using W3C's Resource Description Language, see [RDF]. 2.4 Designing documents with HTML 4.0 We recommend that authors and implementors observe the following general principles when working with HTML 4.0. 2.4.1 Separate structure and presentation HTML has its roots in SGML which has always been a language for the specification of structural markup. As HTML matures, more and more of its presentational elements and attributes are being replaced by other mechanisms, in particular style sheets. Experience has shown that separating the structure of a document from its presentational aspects reduces the cost of serving a wide range of platforms, media, etc., and facilitates document revisions. 2.4.2 Consider universal accessibility to the Web To make the Web more accessible to everyone, notably those with disabilities, authors should consider how their documents may be rendered on a variety of platforms: speech-based browsers, braille-readers, etc. We do not recommend that designers limit their creativity, only that they consider alternate renderings in their design. HTML offers a number of mechanisms to this end (e.g., the alt attribute, the accesskey attribute, etc.) Furthermore, authors should keep in mind that their documents may be reaching a far-off audience with different computer configurations. In order for documents to be interpreted correctly, designers should include in their documents information about the natural language and direction of the text, how the document is encoded, and other issues related to internationalization. 2.4.3 Help user agents with incremental rendering By carefully designing their tables and making use of new table features in HTML 4.0, designers can help user agents render documents more quickly. Authors can learn how to design tables for incremental rendering in the definition of the TABLE element. Implementors should consult the notes on tables in the appendix for information on incremental algorithms. 3 On SGML and HTML Contents 1. Introduction to SGML 2. SGML constructs used in HTML 1. Elements 2. Attributes 3. Entities 4. Comments 3. How to read the HTML DTD 1. DTD Comments 2. Parameter entity definitions 3. Element declarations 4. Attribute definitions This section of the document introduces SGML and discusses its relationship to HTML. A complete discussion of SGML is left to the SGML standard (see [ISO8879]). 3.1 Introduction to SGML SGML is a system for defining markup languages. Authors "mark up" their documents by representing structural, presentational, and semantic information alongside content. HTML is one example of a markup language. Here is an example of an HTML document: My first HTML document

Hello world! An HTML document is divided into a head section (here, between and ) and a body (here, between and ). The title of the document appears in the head, and the bulk of the document appears in the body. This document body contains just one paragraph, marked up with

. Each markup language defined in SGML is called an SGML application. An SGML application is generally characterized by: 1. An SGML declaration. The SGML declaration specifies which characters and delimiters may appear in the application. 2. A document type declaration (DTD). The DTD defines the syntax of markup constructs. The DTD may include additional definitions such as character entity references. 3. A specification that describes the semantics to be ascribed to the markup. This specification also imposes syntax restrictions that cannot be expressed within the DTD. 4. Document instances containing data (content) and markup. Each instance contains a reference to the DTD to be used to interpret it. The HTML 4.0 specification includes an SGML declaration, three document type declarations (see the section on HTML version information for a description of the three), and a list of character references. 3.2 SGML constructs used in HTML The following sections introduce SGML constructs that are used in HTML. The appendix lists some SGML features that are not widely supported by HTML tools and user agents and should be avoided. 3.2.1 Elements An SGML document type definition declares element types that represent structures or desired behavior. HTML includes element types that represent paragraphs, hypertext links, lists, tables, images, etc. Each element type declaration generally describes three parts: a start tag, content, and an end tag. The element's name appears in the start tag (written ) and the end tag (written ); note the slash before the element name in the end tag. For example, the start and end tags of the UL element type delimit the items in a list:

  • ...list item 1...

  • ...list item 2...

Some HTML element types allow authors to omit end tags (e.g., the P and LI element types). A few element types also allow the start tags to be omitted; for example, HEAD and BODY. The HTML DTD indicates for each element type whether the start tag and end tag are required. Some HTML element types have no content. For example, the line break element BR has no content; its only role is to terminate a line of text. Such "empty" elements never have end tags. The document type definition and the text of the specification indicate whether an element type is empty (has no content) or, if it can have content, what is considered legal content. Element names are always case-insensitive. Elements are not tags. Some people refer to elements as tags (e.g., "the P tag"). Remember that the element is one thing, and the tag (be it start or end tag) is another. For instance, the HEAD element is always present, even though both start and end HEAD tags may be missing in the markup. All the element types declared in this specification are listed in the element index. 3.2.2 Attributes Elements may have associated properties, called attributes, which may have values (by default, or set by authors or scripts). Attribute/value pairs appear before the final ">" of an element's start tag. Any number of (legal) attribute value pairs, separated by spaces, may appear in an element's start tag. They may appear in any order. In this example, the id attribute is set for an H1 element:

This is an identified heading thanks to the id attribute

By default, SGML requires that all attribute values be delimited using either double quotation marks (ASCII decimal 34) or single quotation marks (ASCII decimal 39). Single quote marks can be included within the attribute value when the value is delimited by double quote marks, and vice versa. Authors may also use numeric character references to represent double quotes (") and single quotes ('). For double quotes authors can also use the character entity reference ". In certain cases, authors may specify the value of an attribute without any quotation marks. The attribute value may only contain letters (a-z and A-Z), digits (0-9), hyphens (ASCII decimal 45), and periods (ASCII decimal 46). We recommend using quotation marks even when it is possible to eliminate them. Attribute names are always case-insensitive. Attribute values are generally case-insensitive. The definition of each attribute in the reference manual indicates whether its value is case-insensitive. All the attributes defined by this specification are listed in the attribute index. 3.2.3 Entities Character references are numeric or symbolic names for characters that may be included in an HTML document. They are useful for referring to rarely used characters, or those that authoring tools make it difficult or impossible to enter. You will see character entities throughout this document; they begin with a "&" sign and end with a semi-colon (;). Some common examples include: * "<" represents the < sign. * ">" represents the > sign. * """ represents the " mark. * "å" (in decimal) represents the letter "a" with a small circle above it. * "И" (in decimal) represents the Cyrillic capital letter "I". * "水" (in hexadecimal) represents the Chinese character for water. We discuss HTML character entities in detail later in the section on the HTML document character set. The specification also contains a list of character references that may appear in HTML 4.0 documents. 3.2.4 Comments HTML comments have the following syntax: White space is not permitted between the markup declaration open delimiter(""). A common error is to include a string of hyphens ("---") within a comment. Authors should avoid putting two or more adjacent hyphens inside comments. Information that appears between comments has no special meaning (e.g., character references are not interpreted as such). 3.3 How to read the HTML DTD Each element and attribute declaration in this specification is accompanied by its document type definition fragment. We have chosen to include the DTD fragments in the specification rather than seek a more approachable, but longer and less precise means of describing an element's properties. The following tutorial should allow readers unfamiliar with SGML to read the DTD and understand the technical details of the HTML specification. 3.3.1 DTD Comments In DTDs, comments may spread over one or more lines. In the DTD, comments are delimited by a pair of "--" marks, e.g. Here, the comment "named property value" explains the use of the PARAM element type. Comments in the DTD are informative only. 3.3.2 Parameter entity definitions The HTML DTD begins with a series of parameter entity definitions. A parameter entity definition defines a kind of macro that may be referenced and expanded elsewhere in the DTD. These macros may not appear in HTML documents, only in the DTD. Other types of macros, called character references, may be used in the text of an HTML document or within attribute values. When the parameter entity is referred to by name in the DTD, it is expanded into a string. A parameter entity definition begins with the keyword . The following example defines the string that the %font entity will expand to. The string the parameter entity expands to may contain other parameter entity names. These names are expanded recursively. In the following example, the %inline parameter entity is defined to include the %font, %phrase, %special and %formctrl parameter entities. You will encounter two DTD entities frequently in the HTML DTD: %block and %inline. They are used when the content model includes block-level and inline elements, respectively (defined in the section on the global structure of an HTML document). 3.3.3 Element declarations The bulk of the HTML DTD consists of the declarations of element types and their attributes. The character ends it. Between these are specified: 1. The element's name. 2. Whether the element's end tag is optional. Two hyphens that appear after the element name mean that the start and end tags are mandatory. One hyphen followed by the letter "O" indicates that the end tag can be omitted. A pair of letter "O"s indicate that both the start and end tags can be omitted. 3. The element's content, if any. The allowed content for an element is called its content model. Element types that are designed to have no content are called empty elements. The content model for such element types is declared using the keyword "EMPTY". In this example: * The element type being declared is UL. * The two hyphens indicate that both the start tag
    and the end tag
for this element type are required. * The content model for this element type is declared to be "at least one LI element". Below, we explain how to specify content models. This example illustrates the declaration of an empty element type: * The element type being declared is IMG. * The hyphen and the following "O" indicate that the end tag can be omitted, but together with the content model "EMPTY", this is strengthened to the rule that the end tag must be omitted. * The "EMPTY" keyword means that instances of this type must not have content. Content model definitions The content model describes what may be contained by an instance of an element type. Content definitions may include: * The names of allowed or forbidden element types (e.g., the UL element contains instances of the LI element type, and the P element type may not contain other P elements). * DTD entities (e.g., the LABEL element contains instances of the %inline parameter entity). * Document text (indicated by the SGML construct "#PCDATA"). Text may contain character references. Recall that these begin with & and end with a semicolon (e.g., "Hergé's adventures of Tintin" contains the character entity reference for the "e acute" character). The content model uses the following syntax to define what markup an element may contain: ( ... ) Specifies a group. A | B Either A or B must occur but not both. A , B Both A and B must occur in that order. A & B Both A and B must occur, but may do so in any order. A? A can occur zero or one times A* A can occur zero or more times A+ A can occur one or more times Here are some examples from the HTML DTD: The SELECT element must contain one or more OPTION elements. The DL element must contain one or more DT or DD elements in any order. The OPTION element may only contain text and entities, such as & -- this is indicated by the SGML data type #PCDATA. A few HTML element types use an additional SGML feature to exclude elements from content model. Excluded elements are preceded by a hyphen. Explicit exclusions override permitted elements. In this example, the -(A) signifies that the element A cannot appear in another A element (i.e., anchors may not be nested). Note that the A element type is part of the DTD parameter entity %inline, but is excluded explicitly because of -(A). Similarly, the following element type declaration for FORM prohibits nested forms: 3.3.4 Attribute definitions The . An attribute definition is a triplet that defines: * The name of an attribute. * The type of the attribute's value or an explicit set of possible values. Values defined explicitly by the DTD are case-insensitive. Please consult the section on basic HTML data types for more information about attribute value types. * Whether the default value of the attribute is implicit (keyword "#IMPLIED"), in which case the default value must be supplied by the user agent (in some cases via inheritance from parent elements); always required (keyword "#REQUIRED"); or fixed to the given value (keyword "#FIXED"). Some attributes explicitly specify a default value for the attribute. In this example, the name attribute is defined for the MAP element. The attribute is optional for this element. The type of values permitted for the attribute is given as CDATA, an SGML data type. CDATA is text that may contain character references. For more information about "CDATA", "NAME", "ID", and other data types, please consult the section on HTML data types. The following examples illustrate several attribute definitions: rowspan NUMBER 1 -- number of rows spanned by cell -- http-equiv NAME #IMPLIED -- HTTP response header name -- id ID #IMPLIED -- document-wide unique id -- valign (top|middle|bottom|baseline) #IMPLIED The rowspan attribute requires values of type NUMBER. The default value is given explicitly as "1". The optional http-equiv attribute requires values of type NAME. The optional id attribute requires values of type ID. The optional valign attribute is constrained to take values from the set {top, middle, bottom, baseline}. DTD entities in attribute definitions Attribute definitions may also contain parameter entity references. In this example, we see that the attribute definition list for the LINK element begins with the %attrs parameter entity. Start tag: required, End tag: forbidden The %attrs parameter entity is defined as follows: The %coreattrs parameter entity in the %attrs definition expands as follows: The %attrs parameter entity has been defined for convenience since these attributes are defined for most HTML element types. Similarly, the DTD defines the %URL parameter entity as expanding into the string "CDATA". As this example illustrates, the parameter entity %URL provides readers of the DTD with more information as to the type of data expected for an attribute. Similar entities have been defined for %Color, %Charset, %Length, %Pixels, etc. Boolean attributes Some attributes play the role of boolean variables (e.g., the selected attribute for the OPTION element). Their appearance in the start tag of an element implies that the value of the attribute is "true". Their absence implies a value of "false". Boolean attributes may legally take a single value: the name of the attribute itself (e.g., selected="selected"). This example defines the selected attribute to be a boolean attribute. selected (selected) #IMPLIED -- reduced inter-item spacing -- The attribute is set to "true" by appearing in the element's start tag: