# 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.

## 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.

## Associating Classes with Elements

When you create new classes with the Create Rule command, you can associate these classes with some elements in the document.

1. Choose Apply Class from the Style menu.

2. A dialog displays all existing classes. Choose one of these classes.

   Amaya displays the selected elements with the style associated with the chosen class.

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