# Giving attributes to an element

If an HTML element has attributes, they can be asked about in two different ways: either in a dialog box with all attributes (the default), or in the status bar. In the general preferences dialog you can select which of these two ways you want to use. You can use different settings for when you give attributes to and insert a new tag and when you want to change an existing one.

The attributes can be divided into eight categories: URLs, colors, target windows, predefined choices (for example ALIGN=LEFT|CENTER|RIGHT), numbers, flags, event handlers, and other. The category 'other' contains attributes which can take any value plus some which do not fit into any of the other categories.

You can customize which attributes to be asked about. More about that on the next page. Let us first describe how to give values to the attributes.

## Using dialog boxes

The picture above shows the dialog box for a made-up HTML element I have called ELEMENT, which has one attribute of each kind.

#### URLs

You can specify the URL in three ways:

1. type the URL in the text box,
2. choose one from the menu with your URL cache,
3. select a file via a file dialog. The file you have selected will be put in the menu.

It is probably much faster to type the URL than selecting a file from a file dialog, but the advantage to using the file dialog is that it will automatically insert a correct absolute or relative URL depending on which is appropriate. If you use a BASE tag in the current window it will be noticed.

Files inside home page folders are mapped to a URL http://as.you.have.defined.it/file.html and files outside the home page folders are mapped to a URL file:///path/to/file.html

Alpha first determines the URL of the two files, and then determines the URL to link between them.

- If you link within a home page folders you will get a relative URL.
- If you link between two different home page folders like http://here.net/ and http://there.net/ you will get an absolute URL.
- If you link between two different home page folders like http://www.net/~me/ and http://www.net/~you/ (at the same server), you will get a relative URL.

You can also make links between files which are not in a home page folder, but linking between files, where one is inside a home page folder and the other one is not, may not always make sense.

If you type a URL in the text box, it will be used even if you choose something from the menu.

If you select a GIF or JPEG file for the attribute SRC to IMG via a file dialog, the attributes WIDTH and HEIGHT are automatically determined. The algorithm for JPEGs is taken from the perl script 'wwwimagesize' by Alex Knowles, alex@ed.ac.uk and Andrew Tong, werdna@ugcs.caltech.edu

#### Colors

You can specify the color in three ways:

1. type a hexadecimal number #RRBBGG, which defines the color, in the text box,
2. choose a color from the menu,
3. define a new color. The color so defined will be put in the menu.

If you type something in the text box, it will be used, even if you choose a color from the menu.

#### Window

You can specify the target window in two ways:

1. type the window name in the text box,
2. choose a window name from the menu with your window cache.

If you type something in the text box, it will be used, even if you choose a window from the menu.

#### Predefined choices

Select a choice from the menu.

#### Numbers

Attributes which take an integer value. The numbers will be checked that they are in the valid range.

#### Other

Attributes which can take any value. Note that spaces in the beginning and end of what you type are not removed. (This is always done otherwise.) This is because sometimes such spaces are wanted.

#### Flags

These are attributes which does not take any value. Check the checkbox to use it.

#### Event handler

Attributes which event handlers for JavaScript.

If an element has very many attributes, the dialog box may have to be divided into two, or possibly three, pages to fit your screen. Then there will be a menu in the upper left corner of the dialog box to switch between the pages. The dialog box is made as large as possible before being split into two or three pages.

Alpha will complain if you forget a required attribute, and in most cases it will complain if you give a value to an attribute which is not valid.

## Using the status bar

By default not all attributes are asked about. See the next page how to determine which attributes to be asked about.

By default, Alpha beeps and flashes the status bar for the first attribute it asks you about in order to attract your attention. You can turn off the beep and the flashing in the general preferences dialog.

For each attribute you will get a prompt in the status bar. When an attribute is optional, "(optional)" is added to the prompt. See the pictures below:

You can simply type the value you want for an attribute (for colors you can either type a number #RRBBGG or a color name), but some keys have special functions to speed up your work.

tab - If you are asked about an attribute with predefined choices, for example ALIGN=LEFT|CENTER|RIGHT, tab will match what you have typed against your options, and attempt to complete what you have typed. Suppose you type C and then tab. The letters ENTER will then automatically be inserted. The same is true if you are asked for a URL, a target window or a color. Tab will then match against your URL cache, the window cache or the color names defined.

double tab - If there are predefined choices or you are asked for a URL, a color or a target window, double tab will put up a list with everything that match what you have typed so far. If you, for example, have forgotten which choices there are, hit double tab without typing anything to get a list with all possible choices. Once you have chosen something from the list, Alpha immediately jumps to ask you about the next attribute.

cmd-v - Pastes the clipboard into the status bar. This is useful, for example, if you want to insert a URL which you have in another file.

ctrl-f - If you want to select a file via a file dialog when asked for a URL, or define a new color when asked for a color, type ctrl-f in the status bar. Once you have selected a file or defined a new color, Alpha immediately jumps to ask you about the next attribute.

If you select a GIF or JPEG file for the attribute SRC to IMG via a file dialog, the attributes WIDTH and HEIGHT are automatically determined. Just hit return for the WIDTH and HEIGHT attributes and the automatically determined values will be used.

ctrl-q - Skips the current and subsequent attributes. You do not have to go through the whole list of attributes.

ctrl-d - Sometimes there is a default value for an attribute. In particular when you are changing an existing tag the current value is given as default. This default value is given within brackets in the prompt:

If you type a new value it will be used and if you just hit return without giving a value, the default one will be used. In this case, if you don't want any value at all, type ctrl-d to skip this attribute.

escape - Deletes everything written.

ctrl-z - Cancel everything.

If there are predefined choices, only the letters which match a choice can be typed. If you type anything else you just get a beep. Also, when there are predefined choices, if you have typed a unique subset of one of them and hit return, the rest will be added. For example, if the choices are ALIGN=LEFT|CENTER|RIGHT and you type R and then return, you will get ALIGN=RIGHT. If what you have typed is not unique, the attribute will be skipped. There are a few cases when two letters are needed to get a unique choice.

Giving no value at all to an attribute means that you skip it. If you try to skip a required attribute, it is asked for again.