HTML and Style Sheets                                                23 Jan 96

   INTERNET DRAFT                                 Bos, Raggett & Lie,
   Expires in six months                          World Wide Web Consortium

                            HTML and Style Sheets

                        <draft-ietf-html-style-01.txt>

Status of this Memo

   This document is an Internet draft. Internet drafts are working
   documents of the Internet Engineering Task Force (IETF), its areas
   and its working groups. Note that other groups may also distribute
   working information as Internet drafts.

   Internet Drafts are draft documents valid for a maximum of six
   months and can be updated, replaced or obsoleted by other documents
   at any time. It is inappropriate to use Internet drafts as reference
   material or to cite them as other than as "work in progress".

   To learn the current status of any Internet draft please check the
   "lid-abstracts.txt" listing contained in the Internet drafts shadow
   directories on ftp.is.co.za (Africa), nic.nordu.net (Europe),
   munnari.oz.au (Pacific Rim), ds.internic.net (US East coast) or
   ftp.isi.edu (US West coast). Further information about the IETF can
   be found at URL: http://www.ietf.org/

   Distribution of this document is unlimited. Please send comments to
   the HTML working group (HTML-WG) of the Internet Engineering Task
   Force (IETF) at <html-wg@w3.org>. Discussions of this group are
   archived at URL:  http://www.acl.lanl.gov/HTML-WG/archives.html.

   This specification is also available via the Web in hypertext form
   as a Working Draft of the World Wide Web Consortium, see:
   http://www.w3.org/pub/WWW/TR

   Authors:
       Bert Bos <bert@w3.org>,
       Dave Raggett <dsr@w3.org>,
       Hakon Lie <howcome@w3.org>

------------------------------------------------------------------------------
Abstract

   The HyperText Markup Language (HTML) is a simple markup language
   used to create hypertext documents that are portable from one
   platform to another. HTML documents are SGML documents with generic
   semantics that are appropriate for representing information from a
   wide range of applications. This specification extends HTML to
   provide support for style rules expressed in separately specified
   notations. It is no longer necessary to extend HTML when new styles
   are needed. Style rules can be (a) included with individual HTML
   elements to which they apply, (b) grouped together in the document
   head, or (c) placed in associated style sheets. This specification

Bos, Raggett & Lie                                                      Page 1



HTML and Style Sheets                                                23 Jan 96

   does not specify particular style sheet notations, leaving that to
   other specifications.

Contents

   *   Associating HTML documents with style sheets  ...................... 2

   *   Media dependencies  ................................................ 3

   *   The LINK element  .................................................. 3

   *   The STYLE element  ................................................. 4

   *   Common attributes  ................................................. 5

   *   The SPAN element  .................................................. 7

   *   The DIV element  ................................................... 7

   *   User interface and user supplied style sheets

   *   Performance issues  ................................................ 9

   *   Limitations of this specification  ................................. 9

   *   References  ....................................................... 10

Associating HTML documents with Style Sheets

   There are several approaches for associating HTML documents with
   separate style sheets:

   User applied style sheets
       The user agent may provide the means for users to select and
       apply style sheets.



   Implicit associations
       The appropriate style sheet may be implied by the URL or other
       information describing the resource. This approach allows style
       sheets to be retrieved in advance of, or at the same time as,
       the HTML document itself. Implicit associations are not defined
       in this report.



   Explicit associations
       The author can specify one or more alternative style sheets for
       an HTML document using one of the methods described below.




Bos, Raggett & Lie                                                      Page 2



HTML and Style Sheets                                                23 Jan 96

   In HTML it is also possible to put style sheets in-line in the
   document. HTML is extended with a new element and a new attribute
   (both called STYLE), as described below. No matter how style is
   associated with HTML, the user should be made aware that a
   particular style has been applied and should have the option of
   turning it off.

   To make it easier to apply a style to parts of a document, two new
   elements for use in the body of an HTML document are defined: DIV
   and SPAN. The first is to enclose a division (chapter, section,
   etc.) of a document, making it possible to give a whole section a
   distinctive style. The latter is used within paragraphs, similarly
   to EM, but in cases where none of the other HTML elements (EM,
   STRONG, VAR, CODE, etc.) apply.

Media dependencies

   Styles may often be designed for a restricted range of media, e.g.
   for graphical user interfaces with scalable fonts and millions of
   colors; for A4 paper media; for speech output; or for simple
   terminals with one monospace font. This proposal doesn't provide an
   explicit means to state the conditions under which a given style
   sheet is applicable.

   Style sheet notations may themselves provide support for media
   dependencies. Another approach is to use a generic URL to reference
   a style sheet, and to make the binding to a specific URL according
   to the media required. This will be described in a separate working
   draft.

The LINK element

   In HTML, the LINK element is used to create a typed hyperlink
   between the document and some other resource. The REL attribute
   defines the type of the link. With REL=stylesheet, the LINK element
   can also be used to link to a style sheet.

   Authors can use LINK elements to offer readers a choice of style
   sheets, e.g:

       <LINK TITLE="Old" REL=stylesheet HREF="old.style" TYPE="application/dsssl">
       <LINK TITLE="New" REL=stylesheet HREF="new.style" TYPE="application/rtf">
       <LINK TITLE="Wacky" REL=stylesheet HREF="wacky.style" TYPE="text/css">
       <TITLE>ACME Widgets Corp</TITLE>

       <H1>ACME Widgets Corp</H1>
       <P>If your browser supports style sheets, try our new look
       in old, new and wacky styles.

       ...

   This specification builds upon the definition of the LINK element in
   HTML 2.0 (RFC 1866) in the following respects:

Bos, Raggett & Lie                                                      Page 3



HTML and Style Sheets                                                23 Jan 96

       <!ELEMENT LINK - O EMPTY>
       <!ATTLIST LINK
           href    CDATA     #REQUIRED  -- Uniform Resource Locator --
           title   CDATA     #IMPLIED   -- advisory title string --
           rel     CDATA     #IMPLIED   -- forward link type --
           rev     CDATA     #IMPLIED   -- reverse link type --
           type    CDATA     #IMPLIED   -- advisory Internet media type --
           >

   *   The forward link type "stylesheet" is hereby defined to signify
       that the associated LINK element specifies a link to a style
       sheet that may be applied to the HTML document containing the
       LINK element. The HREF attribute specifies the network address
       of the linked style sheet.

   *   If there are several such links, then these are considered as
       providing a choice of alternative style sheets. The character
       string supplied with the TITLE attribute is recommended for use
       in building a menu of alternative styles. Note that the order of
       such LINK elements in the document markup does not signify
       preference order.

   *   The TYPE attribute may be used to specify the Internet Media
       type and associated parameters for the linked style sheet. This
       allows the user agent to disregard style sheets in unsupported
       notations, without the need to first make a remote query across
       the network.

The STYLE element

   A single STYLE element may be included in the document head. It
   allows authors to include style rules within the HTML document, e.g.

       <HEAD>
       <TITLE>Title</TITLE>
       <STYLE TYPE="text/css">
         H1 { color: brown }
         P  { color: blue  }
       </STYLE>
       </HEAD>

   The STYLE element is formally defined by:

       <!ELEMENT style - O (#PCDATA)>
       <!ATTLIST style
           type     CDATA    #REQUIRED -- Internet media type for style --
           title    CDATA    #IMPLIED  -- advisory title for this style --
           >

   The attributes are defined as follows:




Bos, Raggett & Lie                                                      Page 4



HTML and Style Sheets                                                23 Jan 96

   TYPE
       This required attribute defines the style notation as an
       Internet Media type including associated parameters. It is used
       in the same way as with LINK elements. The type applies to style
       rules in the STYLE element as well as those attached with the
       STYLE attribute.



   TITLE
       The user agent is recommended to use the title string when
       building a menu of alternative style sheets. This will only
       happen if the STYLE element occurs together with linked style
       sheets as specified by one or more LINK elements. In the absence
       of such LINK elements, the TITLE attribute may be used to
       describe the style sheet for the purpose of allowing the user to
       turn style sheets on and off.



   The content model for the STYLE element precludes SGML tags, and the
   end tag of a STYLE element can usually be omitted, e.g. when the
   STYLE element is followed by another element. Some characters may
   require escaping with their SGML entity names: "&" followed by a
   letter or "#" character should be represented by "&" while "<"
   followed by a letter, "!" or "?" character should be represented by
   "<".

   When the STYLE element occurs together with one or more LINK
   elements that specify linked style sheets, the user agent should
   consider the STYLE element in preference to the LINK elements. The
   rendering implied by the STYLE element is independent of such LINK
   elements, i.e. it is not cascaded with style sheets specified by
   LINK elements.

Common attributes

   To support effective use of style sheets with HTML documents a
   number of common attributes are proposed. These can be used with
   most HTML elements. In general, all attribute names and values in
   this specification are case insensitive, except where noted
   otherwise.


   <!ENTITY % attrs
          "id      ID       #IMPLIED  -- element identifier --
           class   NAMES    #IMPLIED  -- for subclassing elements --
           style   CDATA    #IMPLIED  -- rendering annotation --
           lang    NAME     #IMPLIED  -- as per RFC 1766 --
           dir   (ltr|rtl)  #IMPLIED  -- I18N text direction --">




Bos, Raggett & Lie                                                      Page 5



HTML and Style Sheets                                                23 Jan 96

   ID
       Used to define a document-wide identifier. This can be used for
       naming positions within documents as the destination of a
       hypertext link. It may also be used by style sheets for
       rendering an element in a unique style. An ID attribute value is
       an SGML NAME token. NAME tokens are formed by an initial letter
       followed by letters, digits, "-" and "." characters. The letters
       are restricted to A-Z and a-z.

   CLASS
       A space separated list of SGML NAME tokens. CLASS names specify
       that the element belongs to the corresponding named classes.
       These may be used by style sheets to provide class dependent
       renderings.

   STYLE
       A text string providing rendering information specific to this
       element. The notation is specified with the STYLE element in the
       document head.

       For example:

           <TITLE>Test Document</TITLE>
           <STYLE TYPE="text/css">
           <P STYLE="color: red; font-style: small-caps">This text should
            be in small capitals and colored red!

       The end tag for the STYLE element has been omitted here since
       the element is unambiguously ended by the <P> start tag.



   LANG
       A LANG attribute identifies the natural language used by the
       content of the associated element.The syntax and registry of
       language values are defined by RFC 1766. In summary the language
       is given as a primary tag followed by zero or more subtags,
       separated by "-". White space is not allowed and all tags are
       case insensitive. The name space of tags is administered by
       IANA. The two letter primary tag is an ISO 639 language
       abbreviation, while the initial subtag is a two letter ISO 3166
       country code. Example values for LANG include:

             en, en-US, en-uk, i-cherokee, x-pig-latin.

   DIR
       Human writing systems are grouped into scripts, which determine
       amongst other things, the direction the characters are written.
       Elements of the Latin script are nominally left to right, while
       those of the Arabic script are nominally right to left. These
       characters have what is called strong directionality. Other
       characters can be directionally neutral (spaces) or weak
       (punctuation).

Bos, Raggett & Lie                                                      Page 6



HTML and Style Sheets                                                23 Jan 96

       The DIR attribute specifies an encapsulation boundary which
       governs the interpretation of neutral and weakly directional
       characters. It does not override the directionality of strongly
       directional characters. The DIR attribute value is one of LTR
       for left to right, or RTL for right to left, e.g. DIR=RTL.

The SPAN element

       <!ELEMENT span O O (%text)*>
       <!ATTLIST span
               %attrs;     -- id, class, style, lang and dir --
               >

   Sometimes it is desirable to apply a style to some text which
   doesn't have a structural role or established rendering convention.
   For instance, the first few words of an article may be rendered as
   small capital letters ("small-caps"). In such situations it is
   inappropriate to use an existing tag such as EM: on existing user
   agents the first few words would be mysteriously italicized. The new
   SPAN tag is recommended instead, as it has no effect on existing
   user agents.

   An example based on CSS:

       <TITLE>Title</TITLE>
       <STYLE TYPE="text/css">
       SPAN { font-style: small-caps }
       </STYLE>
       <P><SPAN>The first</SPAN> few words of this
       article is in small-caps.

   This would be formatted to look something like:

       THE FIRST few words of this
       article is in small-caps.

   While on an existing user agent it would look like:

       The first few words of this
       article is small-caps.


   The SPAN element can be used anywhere that the HTML EM element is
   allowed.

The DIV element

       <!ELEMENT div - - (%body.content)*>
       <!ATTLIST div
               %attrs;     -- id, class, style, lang and dir --
               align    (left|center|right|justify)  #IMPLIED
               >


Bos, Raggett & Lie                                                      Page 7



HTML and Style Sheets                                                23 Jan 96

   The DIV element is used with the CLASS attribute to represent
   different kinds of containers, e.g. chapter, section, abstract, or
   appendix. DIV allows the enclosed group of elements to be given a
   distinctive style. For example:

       <DIV CLASS=Abstract>
       <P>The Chieftain product range is the white-hot hope for the
       coming year. This report sets out how to position Chieftain
       against competing products.

       <P>Chieftain replaces the Commander range, which will
       remain on the price list until further notice.
       </DIV>

   The DIV element can be used anywhere that the HTML P element is
   allowed. The content model for DIV allows headers, lists, paragraphs
   as well as other DIV elements etc. This allows DIVs to be nested, to
   form hierarchies of chapters, sections, and subsections etc.

   DIV can be used with an ALIGN attribute to specify the default
   horizontal alignment for the contents of the DIV element. This is
   needed for compatibility with deployed browsers and may be overriden
   by style sheets.

   ALIGN=LEFT
       Lines are aligned flush left

   ALIGN=CENTER
       Lines are centered.

   ALIGN=RIGHT
       Lines are aligned flush right

   ALIGN=JUSTIFY
       Lines are justified where practical, otherwise this has the same
       effect as ALIGN=LEFT

User interface and user supplied style sheets

   In an interactive user agent, the user should be made aware that a
   particular style sheet has been applied, and be given the option of
   turning it off or selecting a different style. A flag in the corner
   of the window and a toggle in a menubar can be sufficient.

   It may be possible for the user to combine several of the available
   style sheets. It should be possible for the user to choose a
   personal style instead of, or in combination with, style sheets
   supplied by the author.

   When a user agent applies a style sheet to a document while the
   author of that document has indicated a preference for a different
   style sheet, the user agent may have to alert the user to that fact.
   Exactly how and when that is done is outside the scope of this

Bos, Raggett & Lie                                                      Page 8



HTML and Style Sheets                                                23 Jan 96

   report. E.g., the CSS style sheet language gives rules for the
   conditions under which a user is allowed to override the author's choices.

Performance issues

   Some people have voiced concerns over performance issues for style
   sheets. For instance, fetching a LINKed style sheet may delay the
   full presentation for the user. A similar situation arises if the
   document head includes a lengthy set of style rules.

   The current proposal sidesteps these issues by allowing authors to
   include rendering instructions within each HTML element. The
   rendering information is then always available by the time the user
   agent wants to render each element.

   In many cases, authors will take advantage of a common style sheet
   for a group of documents. In this case, distributing style rules
   throughout the document will actually lead to worse performance than
   using a linked style sheet, since for most documents, the style
   sheet will already be present in the local cache. The public
   availability of good style sheets will encourage this effect.

Limitations of this specification

   This specification limits the number of STYLE elements to one per
   document. If later revisions allow multiple STYLE elements in the
   document head (e.g. to cater for alternative styles) one will need a
   different way of specifying the style notation for STYLE attributes
   on the elements in the document body. The suggested choice is an
   attribute on the BODY element, e.g. "styletype", with the same
   definition as the "type" attribute for the STYLE element.

   Also, there is no way to specify that two or more style sheet are to
   be merged. A common case is where the style of a document is based
   on an organization-wide style sheet (which is likely to be cached),
   but needs document-specific overrides. This functionality may be
   added in the future, but can also be provided by the style sheet
   notation itself, e.g. in CSS one can specify:

       <HEAD>
       <TITLE>Title</TITLE>
       <STYLE TYPE="text/css">
         @import "house-style.css"
         @import "draft-report.css"
         H1 { color: red }     /* override cascaded style sheets */
       </STYLE>
       </HEAD>







Bos, Raggett & Lie                                                      Page 9



HTML and Style Sheets                                                23 Jan 96

References

   RFC 1866
       "Hypertext Markup Language - 2.0" by T. Berners-Lee & D.
       Connolly, November 1995. This document can be downloaded from
       ftp://ds.internic.net/rfc/rfc1866.txt.

   RFC 1766
       "Tags for the Identification of Languages", by H. Alvestrand,
       UNINETT, March 1995. This document can be downloaded from
       ftp://ds.internic.net/rfc/rfc1766.txt.

   CSS
       "Cascading style sheets" by Hakon Lie & Bert Bos, December 1995.
       The latest version of this document can be downloaded from
       http://www.w3.org/pub/WWW/TR/WD-css1.html

------------------------------------------------------------------------------
    The World Wide Web Consortium: http://www.w3.org/



































Bos, Raggett & Lie                                                     Page 10