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 that is given in 8.2, "SGML Declaration for HTML". According to its document character set, `*' 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 9. P 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' (8.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 repertoire of ISO 646 IRV. Data characters are drawn from the document character set (see 5, "Character, Words, and Paragraphs"). 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 techniques 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. NOTE - Some historical implementations consider any occurrence of the `>' character to signal the end of a tag. For compatibility with such implementations, when `>' appears in an attribute value, it should be represented with a numeric character reference. For example, `' should be written `' or `'. * A name token (a sequence of letters, digits, periods, or hyphens). NOTE - Some historical implementations allow any character except space or `>' in a name token. In this example, is the element name, src is the attribute name, and `http://host/dir/file.gif' is the attribute value: 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 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, use a comment declaration. A comment declaration consists of `'. Each comment starts with `--' and includes all text up to and including the next occurrence of `--'. In a comment declaration, white space is allowed after each comment, but not before the first comment. The entire comment declaration is ignored. NOTE - Some historical HTML implementations incorrectly consider any `>' character to be the termination of a comment. For example:
HTML Comment Example
2.2.6. Example HTML Document
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 level 1 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 level, charset Encoding considerations any encoding is allowed Security considerations see 3.3, "Security Considerations" The optional parameters are defined as follows: Level The level parameter specifies the feature set used in the document. The level is an integer number, implying that any features of same or lower level may be present in the document. Level 1 is all features defined in this specification except those that require the