HTML Working Group T. Berners-Lee
Some text. *wow*
\-"Some text. "
This is a Heading
Some elements only have a start-tag without an end-tag. For
example, to create a line break, you use the `
' tag. Additionally, the end tags of some other elements, such as Paragraph (`
Some text. *wow*An HTML user agent should use the SGML declaration is given in 11.2, "SGML Declaration for HTML". According to the document character set there,`*' refers to an asterisk character. The instance above is regarded as the following sequence of terminals: 1. TITLE start-tag 2. data characters: ``Parsing Example'' 3. TITLE end-tag 4. P start-tag 5. data characters ``Some text. '' 6. EM start-tag 7. ``*wow*'' 8. EM end-tag The start symbol of the DTD grammar is HTML, and the productions are given in the public text identified by `-//IETF//DTD HTML 2.0//EN' (11.1, "HTML DTD"). Hence the terminals above parse as: HTML | \-HEAD | | | \-TITLE | | | \-
| \-"Some text. " | \-EM | | | \- | | | \-"*wow*" | | | \- | \-2.2. HTML Lexical Syntax SGML specifies an abstract syntax and a reference concrete syntax. Aside from certain quantities and capacities (e.g. the limit on the length of a name), all HTML documents use the reference concrete syntax. In particular, all markup characters are in the ISO-646-IRV character repertoire. Data characters are drawn from the document character set (see 5, "Character Content"). A complete discussion of SGML parsing, e.g. the mapping of a sequence of characters to a sequence of tags and data is left to the SGML standard[SGML]. This section is only a summary. 2.2.1. Data Characters Any sequence of characters that do not constitute markup (see 9.6 ``Delimiter Recognition'' of [SGML]) are mapped directly to strings of data characters. Some markup also maps to data character strings. Numeric character references also map to single-character strings, via the document character set. Each reference to one of the general entities defined in the HTML DTD also maps to a single-character string. For example, abc<def => "abc","<","def" abc<def => "abc","<","def" Note that the terminating semicolon is only necessary when the character following the reference would otherwise be recognized as markup: abc < def => "abc ","<"," def" abc < def => "abc ","<"," def" And note that an ampersand is only recognized as markup when it is followed by a letter or digit: abc & lt def => "abc & lt def" abc & 60 def => "abc & 60 def" A useful technique for translating plain text to HTML is to replace each '<', '&', and '>' by an entity reference or numeric character reference as follows: ENTITY NUMERIC CHARACTER REFERENCE CHAR REF CHARACTER DESCRIPTION & & & Ampersand < < < Less than > > > Greater than NOTE - There are SGML mechanisms, CDATA and RCDATA, to allow most `<', `>', and `&' characters to be entered without the use of entity references. Because these features tend to be used and implemented inconsistently, and because they conflict with techinques for reducing HTML to 7 bit ASCII for transport, they are not used in this version of the HTML DTD. 2.2.2. Tags Tags delimit elements such as headings, paragraphs, lists, character highlighting and links. Most HTML elements are identified in a document as a start-tag, which gives the element name and attributes, followed by the content, followed by the end tag. Start-tags are delimited by `<' and `>'; end tags are delimited by `' and `>'. An example is:
', `', and `' are equivalent, whereas `&' is different from `&'. In a start-tag, the element name must immediately follow the tag open delimiter `<'. 2.2.4. Attributes In a start-tag, white space and attributes are allowed between the element name and the closing delimiter. An attribute typically consists of an attribute name, an equal sign, and a value, though some attributes may be just a value. White space is allowed around the equal sign. The value of the attribute may be either: * A string literal, delimited by single quotes or double quotes and not containing any occurrences of the delimiting character. * A name token (a sequence of letters, digits, periods, or hyphens) In this example, img is the element name, `src' is the attribute name, and `http://host/dir/file.gif' is the attribute value: NOTE - Some historical implementations consider any occurrence of the `>' character to signal the end of a tag. For ompatibility with such implementations, when `>' appears in an attribute value, it should be represented with a numeric character reference, such as in: `'. A useful technique for computing an attribute value literal for a given string is to replace each quote and space character by an entity reference or numeric character reference as follows: ENTITY NUMERIC CHARACTER REFERENCE CHAR REF CHARACTER DESCRIPTION TAB Tab LF Line Feed CR Carriage Return Space " " " Quotation mark & & & Ampersand For example: NOTE - Some historical implementations allow any character except space or `>' in a name token. Attributes values must be quoted only if they don't satisfy the syntax for a name token. Note that the SGML declaration in section 13.3 limits the length of an attribute value to 1024 characters. Attributes such as ISMAP and COMPACT, may be written using a minimized syntax. The markup:
can be written using a minimized syntax:
NOTE - Some historical implementations only understand the minimized syntax. 2.2.5. Comments To include comments in an HTML document that will be eliminated in the mapping to terminals, surround them with `'. After the comment delimiter, all text up to the next occurrence of `-->' is ignored. Hence comments cannot be nested. White space is allowed between the closing `--' and `>', but not between the opening `
HTML Guide: Recommended UsageNOTE - Some historical HTML implementations incorrectly consider any `>' character to be the termination of a comment. 2.2.6. Example HTML Document Structural Example
This is a paragraph in the example HTML file. Keep in mind that the title does not appear in the document text, but that the header (defined by H1) does.
- First item in an ordered list.
- Second item in an ordered list.
- Note that lists can be nested;
- Whitespace may be used to assist in reading the HTML source.
- Third item in an ordered list.
This is an additional paragraph. Technically, end tags are not required for paragraphs, although they are allowed. You can include character highlighting in a paragraph. This sentence of the paragraph is emphasized. Note that the </P> end tag has been omitted.
Be sure to read these bold instructions. 3. HTML as an Internet Media Type An HTML user agent allows users to interact with resources which have HTML representations. At a minimum, it must allow users to examine and navigate the content of HTML documents. HTML user agents should be able to preserve all formatting distinctions represented in an HTML document, and be able to simultaneously present resources referred to by IMG elements. (they may ignore some formatting distinctions or IMG resources at the request of the user). Conforming HTML user agents should support form entry and submission. 3.1. text/html media type This specification defines the Internet Media Type[IMEDIA] (formerly referred to as the Content Type[MIME]) called `text/html'. The following is to be registered with [IANA]. Media Type name text Media subtype name html Required parameters none Optional parameters version, charset Encoding considerations any encoding is allowed Security considerations see 3.3, "Security Considerations" The optional parameters are defined as follows: Version To help avoid future compatibility problems, the version parameter may be used to give the version number of the specification to which the document conforms. The version number appears at the front of this document and within the public identifier of the HTML DTD. This specification defines version 2.0. There is no default. Charset The charset parameter (as defined in section 7.1.1 of RFC 1521[MIME]) may be given to specify the character encoding scheme used to represent the HTML document as a sequence of octets. The default value is outside the scope of this specification; but for example, the default is US-ASCII in the context of MIME mail, and ISO-8859-1 in the context of HTTP. 3.2. HTML Document Representation A message entity with a content type of `text/html' represents an HTML document, consisting of a single text entity. The `charset' parameter (whether implicit or explicit) identifies a character encoding scheme. The text entity consists of the characters determined by this character encoding scheme and the octets of the body of the message entity. 3.2.1. Undeclared Markup Error Handling To facilitate experimentation and interoperability between implementations of various versions of HTML, the installed base of HTML user agents supports a superset of the HTML 2.0 language by reducing it to HTML 2.0: markup in the form of a start-tag or end-tag whose generic identifier is not declared is mapped to nothing during tokenization. Undeclared attributes are treated similarly. The entire attribute specification of an unknown attribute (i.e., the unknown attribute and its value, if any) should be ignored. On the other hand, references to undeclared entities should be treated as data characters. For example:=>
yyy => "xxx ",
," yyy Let α and β be finite sets. => "Let α and β be finite sets." Support for notifying the user of such errors is encouraged. Information providers are warned that this convention is not binding: unspecified behavior may result, as such markup is not conforming to this specification. 3.2.2. Conventional Representation of Newlines SGML specifies that a text entity is a sequence of records, each beginning with a record start character and ending with a record end character (code positions 10 and 13 respectively). (section 7.6.1, ``Record Boundaries'' in [SGML]) [MIME] specifies that a body of type `text/*' is a sequence of lines, each terminated by CRLF, that is octets 10, 13. In practice, HTML documents are frequently represented and transmitted using an end of line convention that depends on the conventions of the source of the document; frequently, that representation consists of CR only, LF only, or CR LF combination. Hence the decoding of the octets will often result in a text entity with some missing record start and record end characters. Since there is no ambiguity, HTML user agents are encouraged to infer the missing record start and end characters. An HTML user agent should treat end of line in any of its variations as a word space in all contexts except preformatted text. Within preformatted text, an HTML user agent should expect to treat any of the three common representations of end-of-line as starting a new line. 3.3. Security Considerations Anchors, embedded images, and all other elements which contain URIs as parameters may cause the URI to be dereferenced in response to user input. In this case, the security considerations of the URI specification apply. The widely deployed methods for submitting forms requests -- HTTP and SMTP -- provide little assurance of confidentiality. Information providers who request sensitive information via forms -- especially by way of the `PASSWORD' type input field -- should be aware and make their users aware of the lack of confidentiality. > 4. Document Structure Elements To identify information as an HTML document conforming to this specification, each document should start with the prologue: NOTE - If the body of a text/html body part does not begin with a document type declaration, an HTML user agent should infer the above document type declaration. HTML user agents are required to support the above document type declaration, the following document type declarations, and no others. In particular, they may support other formal public identifiers, or document types altogether. They may support an internal declaration subset with supplemental entity, element, and other markup declarations, or they may not. 4.1. HTML Document Element ... Level 0 The HTML document element is organized as a head and a body, much like a memo or a mail message. Within the head, you can specify the title and other information about the document. Within the body, you can structure text into paragraphs and lists, as well as highlight phrases and create links, using HTML elements. NOTE - The start and end tags for HTML, Head, and Body elements are omissible; however, this is not recommended since the head/body structure allows an implementation to determine certain properties of a document, such as the title, without parsing the entire document. < 4.2. Head... Level 0 The head of an HTML document is an unordered collection of information about the document. The Title element is required.
Introduction to HTML4.3. Body ... Level 0 The Body element identifies the body component of an HTML document. Specifically, the body of a document may contain links, text, and formatting information within and tags. 4.4. Title ...Level 0 Every HTML document must contain a Title element. The title should identify the contents of the document in a global context, and may be used in history lists and as a label for the window displaying the document. Unlike headings, titles are not rendered in the text of a document itself. The Title element must occur within the head of the document, and must not contain anchors, paragraph tags, or highlighting. Only one title is allowed in a document. NOTE - The length of a title is not limited; however, long titles may be truncated in some applications. To minimize this possibility, titles should be fewer than 64 characters. Also keep in mind that a short title, such as Introduction, may be meaningless out of context. An example of a meaningful title might be ``Introduction to HTML Elements.'' 4.5. Base Level 0 The Base element allows the URI of the document itself to be recorded in situations in which the document may be read out of context. URIs within the document may be in a ``partial'' form relative to this base address[RELURL]. The Base element has one attribute, HREF, which identifies the absolute base URI. 4.6. Isindex Level 0 The Isindex element tells the interpreter that the document is an index. This means that the reader may request a keyword search on the resource by adding a question mark to the end of the document address, followed by a list of keywords separated by plus signs. The Isindex element is usually generated by the network server from which the document was obtained via a URI. The server must have a search engine that supports this feature for the resource. If the document URI is unknown to the interpreter, must be ignored. 4.7. Link Level 0 The Link element indicates a relationship between the document and some other object. A document may have any number of Link elements. The Link element is empty (does not have a closing tag), but takes the same attributes as the Anchor element. Typical uses are to indicate authorship, related indexes and glossaries, older or more recent versions, etc. Links can indicate a static tree structure in which the document was authored by pointing to a ``parent'' and ``next'' and ``previous'' document, for example. Servers may also allow links to be added by those who do not have the right to alter the body of a document. 4.8. Meta Level 0 The META element is used within the HEAD element to embed document metainformation not defined by other HTML elements. META elements can be extracted by servers and/or clients for use in identifying, indexing, and cataloging specialized document metainformation. Although it is generally preferable to use named elements which have well-defined semantics for each type of metainformation (e.g. TITLE), the META element is provided for situations where strict SGML parsing is necessary and the local DTD is not extensible. HTML interpreters may use the META element's content if they recognize and understand the semantics identified by the NAME or HTTP-EQUIV attributes, and may treat the content as metainformation (and not render it) even when they do not recognize the name. In addition, HTTP servers may wish to read the content of the document HEAD to generate header fields corresponding to any elements defining a value for the attribute HTTP-EQUIV. Note, however, that the method by which the server extracts document metainformation is not part of this specification, nor can it be assumed by authors that any given server will be capable of extracting it. The META element only provides an extensible mechanism for identifying and embedding document metainformation - how it may be used is up to the individual server implementation and the HTML interpreter. Attributes of the META element: HTTP-EQUIV This attribute binds the element to an HTTP header field. It means that if you know the semantics of the HTTP header field named by this attribute, then you can process the contents based on a well-defined syntactic mapping, whether or not your DTD tells you anything about it. HTTP header field names are not case sensitive. If not present, the attribute NAME should be used to identify this metainformation and the content should not be used within an HTTP response header. NAME Metainformation name. If the NAME attribute is not present, the name can be assumed to be equal to the value of HTTP-EQUIV. CONTENT The metainformation content to be associated with the given name. If multiple META elements are provided with the same name, their combined contents-concatenated as a comma-separated list-is the value associated with that name. Examples If the document contains: then the server (if so configured) may include the following headers: Expires: Tue, 04 Dec 1993 21:29:02 GMT Keywords: Fred, Barney Reply-to: email@example.com (Roy Fielding) as part of the HTTP response to a GET or HEAD request for that document. When the HTTP-EQUIV attribute is not present, the server should not generate an HTTP response header for the metainformation; e.g., would never generate an HTTP response header, but would still allow HTML interpreters to identify and make use of that metainformation. The Meta element should never be used to define information that should be associated with an existing HTML element. An example of an inappropriate use of the Meta element is: Do not name an HTTP-EQUIV equal to a response header that should normally only be generated by the HTTP server. Example names that are inappropriate include ``Server'', ``Date'', and ``Last-modified'' - the exact list of inappropriate names is dependent on the particular server implementation. We recommend that servers ignore any META elements which specify HTTP-equivalents which are equal (case-insensitively) to their own reserved response headers. 4.9. Nextid Level 0 The Nextid element is a parameter read and generated by text editing software to create unique identifiers. This tag takes a single attribute which is the next document-wide alpha- numeric identifier to be allocated of the form z123: When modifying a document, existing anchor identifiers should not be reused, as these identifiers may be referenced by other documents. Human writers of HTML usually use mnemonic alphabetical identifiers. HTML interpreters may ignore the Nextid element. Support for the Nextid element does not impact HTML interpreters in any way. 5. Character Content An HTML user agent should present the body of an HTML document as a collection of typeset paragraphs and preformatted text. Except for theelement, each block structuring element is regarded as a paragraph by taking the data characters in its content and the content of its descendant elements, concatenating them, and splitting the result into words, separated by space, tab, or record end characters (and perhaps hyphen characters). The sequence of words is typeset as a paragraph by breaking it into lines. 5.1. The ISO Latin 1 Character Repertoire The minimum character repertoire supported by all conforming HTML user agents is Latin Alphabet Nr. 1, or simply Latin-1. Latin-1 includes characters from most Western European languages, as well as a number of control characters. Latin-1 also includes a non-breaking space, a soft hyphen indicator, 93 graphical characters, 8 unassigned characters, and 25 control characters. NOTE - Use the non-breaking space and soft hyphen indicator characters is discouraged because support for them is not widely deployed. In SGML applications, the use of control characters is limited in order to maximize the chance of successful interchange over heterogeneous networks and operating systems. In HTML, only three control characters are allowed: Horizontal Tab (HT, encoded as 9 decimal in US-ASCII and ISO-8859-1), Carriage Return, and Line Feed. The HTML DTD references the Added Latin 1 entity set, to allow mnemonic representation of Latin 1 characters using only the widely supported ASCII character repertoire. For example: Kurt Gödel was a famous logician and mathematician. See 11.4.2, "ISO Latin 1 Character Entity Set" for a table of the ``Added Latin 1'' entities, and 14.1, "The ISO-8859-1 Coded Character Set" for a table of the code positions of ISO-8859-1. 6. Data Elements 6.1. Line Break
Level 0 The Line Break element specifies that a new line must be started at the given point. A new line indents the same as that of line-wrapped text. Example of use:
Pease porridge hot
Pease porridge cold
Pease porridge in the pot
Nine days old. 6.2. Horizontal Rule
Level 0 A Horizontal Rule element is a divider between sections of text such as a full width horizontal rule or equivalent graphic. Example of use:
February 8, 1995, CERN