Cascading Style Sheets (CSS)

The Style menu enables you to change the appearance of your documents using Cascading Style Sheets (CSS)

About Linking External and User Style Sheets

A document can link to several external style sheets that are downloaded with the document and applied to it.

An external style sheet can apply to multiple documents. When the same style sheet applies to several displayed documents, Amaya loads only one instance of the style sheet.

Any user can define a specific style sheet that applies to all documents loaded on their system. This style sheet is called the user's style sheet. It is stored in the user's local environment, in the AmayaHome directory as the local file amaya.css.

For example, if you prefer to display documents in Helvetica on your screen and print them in small size, you can create a user's style sheet with following CSS rules:

@media print {
body {font-size: 10pt}
}
@media screen {
body {font-family: Helvetica}
}

Handling External CSS Style Sheets

The Style menu provides a set of commands which enable you to control external and user's CSS style sheets.

The Open, Disable and Enable commands can be applied to the user's preference style sheet, but the Link and Remove commands apply to only external CSS style sheets.

Creating and Updating some CSS properties

Following Colors, Characters, and Format tools enable you to directly generate CSS properties into a style sheet file.

When the style property is applied and the selection is within a style sheet, Amaya inserts the CSS property at the current position.

Showing Applied Style

If there are a lot of style sheets attached to a document, it's difficult to understand why an element is displayed with that color or these margins, etc. To help the user, Amaya provides a Show applied style command that displays into an external window CSS style properties applied to the first current selected element.

The user can then display the CSS source that generates each property by double (or simple) click on the property. As long as the window is open, Amaya updates the window content when the selection changes. Hitting F2, the user can so see CSS properties applied to enclosing elements.

Associating a Class to an Element

All classes available for the document are listed in the Apply Class tool.

To apply a class to an element:

  1. Choose the right entry within the Apply Class tool.
  2. If you want to select the class applied to another element, you have to select this element, then click the Refresh button. The Apply Class list is refreshed and the current applied class is selected.
  3. Select a piece of text or an element.
    To select an element, you have to click within the element, then use the F2 key until the bottom line of the window displays its type in first position. You can also use the Structure view to select it.
  4. Click the ok button to apply the class to the current selection.
    If a piece of text is selected, Amaya will generate a span element to enclose the current text and the class attribute will be attached to this new span element.

To associate a class with an element, you can also use the Attributes tool. This Attributes tool also enables you to delete a class attribute from an element or to change it (the class attribute is handled like any other attribute).

To remove the class of an element:

Creating and Updating a Style Attribute

Amaya provides tools that let you associate a style attribute with the currently selected elements:

Colors

The Colors tool lets you choose the foreground and background colors from a palette. When the Colors tool is open:

To select a new foreground or background color, one must click the associated button. A palette allows then to freely select a color.

The default option enables you to remove the corresponding style information for the selected elements. Selected colors are not immediately applied to the current selection. The apply button must be clicked.

Note: It's important to selected enough contrasted foreground and background colors.

Characters

The Characters tool lets you choose the font family, the character style, the body size, and the underline style.

The default option enables you to remove the corresponding style information for the selected elements. Selected values are not immediately applied to the current selection. The apply button must be clicked.

Format

The Format tool enables you to set alignment, indentation, justification, and line spacing.

The default option enables you to remove the corresponding style information for the selected elements. Selected values are not immediately applied to the current selection. The apply button must be clicked.

Background image

This entry in the Style menu enables you to choose a background image and its repeat mode.

To add a background image:

  1. Select an element.
    To select an element, you have to click within the element, then use the F2 key until the bottom line of the window displays its type in first position. You can also use the Structure view to select it.
  2. Click the Background image entry in the Style menu to open the dialogue box which enables you to:
    • Enter the Image URI or browse.
    • Select the repeat mode: repeat (repeat), x-repeat ( x-repeat), y-repeat (y-repeat), or no-repeat (no-repeat).

To remove a background image:

Creating a Generic Style for an Element or Class

When a style attribute is associated with an element, you can use that element as a model for creating or modifying a style rule by using the Create Rule command.

To create a generic style for an element or class:

  1. Select the element you wish to use as the template. By default the selection is set to the character string, and you have to press the F2 key to select the enclosing element.

    Note: You must select only one element and this element must have a style attribute.

  2. Choose Create Rule from the Style menu. Amaya opens a dialog displaying a list of CSS selectors. This list contains all classes that are defined for the current document (including those defined in linked CSS style sheets), as well as the element type to which the style is associated.

  3. Choose a selector in this list or enter a new class name and click Confirm.

    The style of the selected element is then associated with the chosen selector and the style attribute is removed from the selected element. Its content is moved to the style element, in the document HEAD, and all elements matching the selector are displayed with the new style.

When a new class is created with the command Create Rule, this class is automatically added to the list of the Apply Class tool.

About Applying Style Using HTML Elements

HTML provides some character-level elements so you can associate style with character strings. Two options on the XHTML menu enable you to handle these HTML elements:

Creating HTML Style Elements

Two submenus on the XHTML menu enable you to add HTML elements to your CSS style sheet: Information Type and Character Elements.

Information Types

The Information Type submenu lists HTML elements that define abstract styles.

To apply an information type:

  1. Select a character string in your page.
  2. Choose an option from the Information Types submenu.

    The selected character string displays in the chosen style.

Three of these styles are also available in the XHTML tool: emphasis (Emphasis button), strong (Strong button) and code (Code button).

Character Elements

The Character Elements submenu of the XHTML menu provides another set of style elements.

To apply a character element:

  1. Select a character string in your page.
  2. Choose an option from the Character Elements submenu.

    The selected character string displays the chosen style.

Removing Style Elements

áAll commands of the submenus Information Types and Character Elements are removed when you apply them twice.

To remove a style element:

  1. Select the element you want to remove. By default the selection is set to the character string, and you have to press the F2 key to select the enclosing element.
  2. Reapply the command from the Information Type or Character Elements submenu of the XHTML menu.