About Arbortext Styler > Document Preview and Publishing > Managing CSS Files in HTML Output
  
Managing CSS Files in HTML Output
Arbortext Styler supports three different methods of outputting CSS information in all HTML outputs (HTML File, Web, HTML Help, and EPUB):
Declaring CSS as values of each element's style attribute.
Specifying CSS in a named style rule in the style element in the HTML document's head section, and then setting the element's class attribute to the name of the style rule. This is the default treatment of CSS information in HTML File output.
Outputting CSS in a named style rule in an external .css file, referencing that file via a link element in the HTML document's head section, and then setting each element's class attribute to the name of the relevant style rule. This is the default treatment of CSS information in chunked HTML outputs - Web, HTML Help, and EPUB.
The .css file is output with a specific file name, depending on the output format chosen:
Chunked HTML outputs (EPUB, HTML Help, and Web) – the file will be named styler.css
HTML File output – the file will be named output_filename.css
It is possible to specify that CSS in a particular output should be treated in a non-default way, and the sections below provide some examples of how this can be accomplished:
Output CSS to an external file in HTML File output
In this procedure you will specify that publishing to HTML File output should output CSS information into a specified external file, rather than writing it into the style element at the head of the HTML file, as is the default behavior for this output type.
1. In Arbortext Styler, choose the File > Stylesheet Properties menu option to open the Stylesheet Properties dialog box for your stylesheet. Note that the dialog box will also open when you elect to create a new stylesheet via the File > New menu option.
2. Select the publishing type HTML File if this has not already been done.
3. Navigate to the HTML tab of the Stylesheet Properties dialog box. In the HTML File group, select the option External file in the CSS style location field. Click OK to save the setting and exit the Stylesheet Properties dialog box.
4. In Arbortext Editor, choose the File > Publish > HTML File menu option. When the publish action is complete, refer to the output. The HTML file output_filename.htm does not contain any embedded CSS, and the file output_filename_files/output_filename.css has been created to contain the CSS information.
The CSS information has been written to the external file output_filename_files/output_filename.css. Note that the directory is named under a particular naming convention - the HTML document output_filename.htm will always be paired with its associated file directory output_filename_files, following standard Windows behavior for connected files. In particular, when you carry out a move, rename, copy or delete action on either the output_filename.htm file or the output_filename_files files directory, the action will always include the other one.
* 
If generated, the output_filename_files directory has the same name for both HTML File and RTF output. If you produce both HTML and RTF output for the same document, and publish them to the same output directory, both outputs will reference the same output_filename_files directory. This could cause issues in certain circumstances:
If, after generating both HTML File and RTF output, you delete/move the .htm file, Windows will also delete/move the output_filename_files directory. If the equivalent RTF output contains linked graphics, these will be lost when the output_filename_files directory is deleted. To avoid this issue, take care to output HTML File and RTF to separate directories, or set your RTF file to use embedded graphics.
Your stylesheet may be set up to treat a graphic in different ways, depending on whether it appears in HTML File or RTF output. In this case it is not acceptable to reference the same output_filename_files directory for both outputs, since this will result in only one version of the graphic being available.
Note also that publishing to HTML File may change the file extension of a graphic, as the process converts graphics to web friendly format. Take care that this will not overwrite a graphic of the same name that is intended to be referenced in RTF output only. For example, a graphic named styler.cgm will be converted to styler.jpg when the document is published to HTML File. If the graphic styler.jpg already exists in the output_filename_files directory, but for RTF output only, this distinction will be lost when the file is overwritten.
It is a good idea to publish HTML File and RTF outputs of the same document to separate directories to avoid these issues.
Declare CSS in elements' style attributes in Web output
In this procedure you will specify that publishing to Web output should declare CSS information in the style attributes of each element in the document, rather than exporting it to an external file. You need to edit the .style file directly, and change the default value of the CSS configuration attribute for the Web output. You can use the same procedure to change the default treatment of CSS information for any of the chunked HTML outputs.
1. In Arbortext Editor, open the .style file that will support publishing your document to Web output. Note: use the File > Open menu option rather than the Styler > Open Stylesheet option, to ensure the stylesheet is opened as an editable document.
2. Add an HtmlOutputConfig element as the child of the StyleSheetInfo element, if one does not already exist.
3. Open the Modify Attributes dialog box for the element, and set the value of the output attribute to web. Set the value of the cssStyleLocation attribute to onElements. Click OK to save the change and exit the dialog box, then close the stylesheet in Arbortext Editor.
4. Still in Arbortext Editor, open the XML document that is to be published via the stylesheet you’ve worked on, and choose the File > Publish > For Web menu option. When the publish action is complete, refer to the output. You will see that, in each of the document chunks in the output directory, each individual element in a chunk has the CSS style information declared in its style attribute.
HtmlOutputConfig elements in your stylesheet define the method by which CSS information will be generated for your document in each of the HTML output types. If an HtmlOutputConfig element does not exist in your stylesheet for a particular HTML output, the default method of CSS generation will be applied when the document is published to that format. You can, however, change the default setting by adding a HtmlOutputConfig element to the stylesheet as described above, then setting the value of its attributes as described below.
The output attribute relates to the possible HTML output types. The permitted values are web, htmlhelp, epub, and htmlfile.
The cssStyleLocation attribute describes the method by which CSS information will be generated. the permitted values are:
externalCssFile - generate a CSS file in the output directory
inHtmlHead - declare all CSS information for the document once, in the head element of the HTML document
onElements - declare all CSS information for the document in the style element of each element in the HTML document