Contents

CSS Containment in HTML

In order for the style sheets to influence the presentation, the user-agent (e.g. browser) must be aware of their existence. The HTML specification define how to link HTML with style sheets.

<HTML>
    <HEAD>
        <TITLE>title</TITLE> 
        <LINK REL=STYLESHEET TYPE="text/css" HREF="http://ucware.com/laf.css" TITLE="Cool">
        <STYLE TYPE="text/css">
            @import url(http://ucware.com/basic.css);
            H1 { color: blue }
            </STYLE>
    </HEAD>
<BODY>
    <H1>Headline</H1>
</BODY>
</HTML>

The example shows three ways to combine style and HTML:

  1. using the 'LINK' element to link an external style sheet;
  2. a 'STYLE' element inside the 'HEAD' element;
  3. and an imported style sheet using the CSS '@import' notation.

The 'LINK' element references alternative style sheets that the reader can select, while imported style sheets are automatically merged with the rest of the style sheet.

Traditionally, UAs have silently ignored unknown tags. As as result, old UAs will ignore the 'STYLE' element, but its content will be treated as part of the document body, and rendered as such. During a transition phase, 'STYLE' element content may be hidden using SGML comments:

 
        <STYLE TYPE="text/css"><!--    
        H1 { color: green }  
        --></STYLE>
    
Since the 'STYLE' element is declared as "CDATA" in the DTD, conforming SGML parsers will not consider the above style sheet to be a comment that is to be removed.

You can attach CSS document to HTML document (method 1 - the 'LINK' element to link an external style sheet; ). In this case, style sheet  stored in separate file and you can use one style sheet for many HTML documents.
For performing this action, you must save currently editing document and invoke Tools -> Attach to HTML file... menu action.

Also you can embed style sheet into HTML documents. In this case, style sheet stored in HTML file is applied only for elements in the HTML file, where style sheet stored. Others HTML documents can't have an access to style sheet stored in HTML document.
Use Tools -> Insert into HTML file... menu action.

See also: Site manager