KompoZer User Guide
4 - Stylesheets
KompoZer User Guide - Section 4
Note Where the icon occurs click it to reveal differences in the behaviour of Nvu if this interests you.
The use of styles is already well established in word processing and desk top publishing. In web site design it assumes an even more important role and can control almost every aspect of presentation.
Styles in HTML documents should comply with the requirements of the W3C style specifications. These are detailed in ‘Cascading Style Sheets, level 2 CSS2 Specification’ which is available at http://www.w3.org/TR/CSS21/.
A full introduction and many useful references may be found at http://en.wikipedia.org/wiki/Cascading_Style_Sheets
Styles specify how particular elements on a page appear on the screen, in print or whatever. This guide limits itself to on-screen considerations. By ‘elements’ we mean parts of the page structure, typically headings and paragraphs, but also stretching to many others including tables, bulleted and numbered lists etc. In fact most HTML ‘Tags’ may be specified though the same style may be applied to several.
Style may typically define such aspects of presentation as the font face, size and variant, the font colour, the background colour, whether an element is to be aligned right, centre or left, whether spaced away from other elements, surrounded by a border and, if so, what type or colour. Elements may be given an absolute position relative to the page (which allows elements to overlap). Elements such as paragraphs, tables and images are considered to exist within boxes or blocks and the sizes of these boxes may be specified.
Note You can see the outlines of the blocks by selecting ‘View - Block outline’.
As well as allowing you to specify the style of elements it is possible to define styles and apply them selectively to only some elements. This is done through ‘Classes’ – a ‘Class’ is just a style that can be applied as and when you choose.
‘Classes’ are applied to ‘Tags’ (a marker attached to an element). The element to which the class is applied appears in the format defined by the class. Other similar elements without the class applied appear in the default format i.e. either the default specified by the browser or the style that the user has defined for the corresponding element.
On the status bar KompoZer shows classes along with the tag to which they are applied.
Within a page styles may be used in three ways. These ways can be mixed and matched as you wish. The first, easiest and crudest is to define a style for the nonce, there and then. Such a style is listed in the code (in Source view) with the tag to which it applies (using the structure “style = ….
” if you look at the code).
Don’t worry KompoZer hides all this from you.
If you have another item with the same style this code must be repeated. This bloats the page. This is known as an ‘inline style’. For the most part KompoZer users do not have to be concerned with this method although KompoZer will sometimes use it without you knowing.
The second way to use a style is to embed a list of style definitions within the HEAD section of a page. (These definitions are referred to as 'style rules' or just 'rules')
These rules may be of one of two sorts. The first sort applies to all elements of a particular type (e.g. p, h1, table) the second is the class as discussed above.
Note If you look at the HTML source code you will see a structure like when the class
"mynicepara
" has been applied. The corresponding code where no class is applied is . If you look at the structure of the style sheet for a class you will see the class name preceded by a dot (full stop) e.g. “
.mynicepara
” while a generally applied style will look like 'p
'. Generally applied styles must, of course, carry the name of the element to which they apply whereas a class can have any name you like to give it. To help maintain the site it is good to give it a name that describes its function NOT the resulting appearance.
While the first two methods are valid and have their uses, the third is the preferred method specifically because it is economical, reuses the same styles for many pages and helps in achieving consistency of appearance right across a complete web site. The method uses an external style sheet which is ‘Linked’ to a page, or to several pages (though each page must include the linking information for itself).
An external style sheet contains the same list of rules which would otherwise have been included in the internal list referred to above. (It is actually a simple text document such as you could construct using a text editor like Windows® Notepad.) The file is usually located in the same folder (directory) as the page to which it is linked (though it can be elsewhere) and has the extension ‘css’.
How does a page know to use this style sheet? A line of code which, KompoZer will insert for you in the head section of your page, will see to this.
Warning This is one of the few places where Nvu makes a mess of things. It inserts an absolute reference instead of a relative reference. This will work fine as long as your pages remain on your own computer but, if you move them to a new folder or upload them you will need to edit this line manually. See section 4.2.4.1
The code looks like <link rel="stylesheet" type="text/css" href="mystylesheet.css
>
You may wonder – if you have an external style sheet, perhaps internal rules and inline styles will there be confusion? This is where the cascading comes in. Your browser should first use whatever its default style would be. If it finds a matching style in an external sheet it should use that instead, it should then look at internal styles and, if any coincide with anything it is planning to use that should override them. Lastly inline styles prevail.
How could that be used? Well perhaps your site establishes a style using an external style sheet. Perhaps you have one page about emergency procedures and you decide that all its paragraphs should be in red. You simply add an internal rule on that page redefining the ‘p’ tag to be red but also link the page to your normal style sheet. All your normal styles will be applied except that all paragraph text will be in red, nothing else will be non-standard.
KompoZer will actually allow you to link several external sheets to a page. The browser reads these in the order encountered and acts on the most recent information read. Internal sheets still obtain priority irrespective of the order they appear in the code.
The full rules for prioritisation are rather complex. Perhaps in an attempt to assist here KompoZer allows you to switch off style sheets while testing pages. With the CSS editor open (see later) select a stylesheet and check the ‘Disabled’ box.
Styles employ a bespoke nomenclature. KompoZer uses this little since, except in source view, the code is hidden from the author. The terms involved do appear in this User Guide. Here they are along with some examples. The examples show the source code that would appear either in the head area of your page or in an external style sheet.
Simple rule with one declaration |
p
{
font-family
:
Arial, sans-serif
;}
|
Rule with 2 declarations |
p
{
font-family
:
Arial, sans-serif
;
font-size
:
medium
;}
|
Rule with 2 selectors |
h1
,
h2
{
color
:
#990000
;}
|
Rule with class selector |
.redtext
{
color
:
red
;}
|
Rule with complex selector * |
#menu li a:link
{
text-decoration
:
none
;}
|
Key:
Rules appear within a blue bordered box
Selectors have a red border and white background
Declarations have a dashed border
Properties have a green border and white background
Values have a magenta border and white background
* This selector selects list items in the div with id 'menu' and which are linked.
CREATING INTERNAL STYLES USING NVU
Styles are created and edited using the built in Style sheet editor called CaScadeS. CaScadeS has two modes of operation ‘Beginner Mode’ and ‘Expert Mode’. When it opens it opens in expert mode, should you wish to switch to Beginner Mode clear the check box. The difference is that in Beginner mode External style sheets cannot be created.
When internal styles are created Nvu will include the the rules for these in the 'head' area of the document.
To start creating styles:
To style an element e.g. a paragraph:
p
”, or the tag for the element (without the quotes)To define how you want elements to look:
As we will see later style rules are stored in style sheets. KompoZer includes a CSS editor called CaScadeS which allows you to create stylesheets and define rules. Before you define a rule you must have a stylesheet but if you are working on a page which has none CaScadeS will create one for you.
To create a style rule for an element
To define how you want elements to look:
Once created, rules may be edited by reopening CaScadeS, Click and expand the stylesheet and click the rule involved.
In the ‘Sheets and rules’ pane on the left you should see a structure showing each tag as it is defined.
I won’t go through all the options, just mention a few.
First, do note you are not obliged to specify any particular properties. You specify as much or as little as you wish. It’s just that the browser will revert to defaults if you don’t. There are fairly complicated rules for what it uses, and browsers don’t always follow the rules, however chances are that you’ll be happy with whatever it does – if you’re not – change it!
You may like to try setting declarations for the ‘body’ and apply it to all elements. In most cases declarations specified here with trickle down to everything else (they are ‘inherited’) unless you specify it explicitly elsewhere. Generally this works but can generate surprises.
Note The tabs available in CaScadeS allow a large number and all the most important style properties to be set. The CSS specification however includes many others. If you are familiar with these you can type declarations manually into the box (incorrectly) headed 'Style rule'. On closing CaScadeS the validity of the declaration will be checked and those which are valid will be added to the stylesheet.
Font family. You are offered three ways of specifying
In common parlance ‘font families’ are referred to as ‘fonts’. CSS always refers to them as ‘font families’. The correct typographic term is ‘Typeface’. (The English word for ‘font’ is ‘fount’ but sadly the American word has come into general use in the UK.)
‘Unspecified’ leaves everything to the browser
‘Predefined’ has a drop down selector offering one of three choices. Each choice has a set of 3 fonts which have fundamentally similar characteristics. The choices are:
Each set has three entries. The first two are alternative similar fonts; the third entry is a statement of the generic font type – the browser should look for the first font listed, if it can’t find it, look for the second and, if that can’t be found, use a font of the generic type of the final entry. Thus something suitable will always be found.
‘Custom font family’ is an option to be avoided or used with extreme caution. The list offered is taken from the fonts installed on the author’s computer. If you choose one which is not available on your visitor’s computer there is no control over what will be used.
On the other hand, if carefully used, this option is very flexible and you can build your own set using the model from the ‘Predefined’ selector.
To build a set of fonts.
Note 1 You will probably wish to include one font available on Windows PC systems and an equivalent available on Macintosh computers.
Note 2 You may enter as many fonts as you wish.
Note 3 Using ‘cursive’ or ‘fantasy’ options is not recommended since the level of standardisation between visitors will render the results very uncertain.
Note 4 If you use a font which has a name which includes spaces (such as Times New Roman) the name must be enclosed within quotes e.g. "Times New Roman". If you fail to do this the result will probably still work but validation will fail.
Warning Unfortunately when Nvu builds sets of fonts itself it fails to do this. The fixed spacing option presents no problem but the two proportional options use fonts with spaces in the font names. Authors must either suffer the indignity of failing validation or edit the style values in source view to overcome the problem.
Font size. There are three sections offering different types of option. The first block is a miscellany offering various units. Because display screens vary in size and resolution and because people’s eyes and preferences differ, browsers offer view options allowing the user to alter the text size. If this facility is disabled the user may not be able to see the page as he or she would wish. Some of the options in this first group (e.g. px, pt, cm, in, mm, pc) either apply to print media or are for fixed size units. These may disable browser zooming or result in unpredictable sizes. You will probably find the last set of named styles (starting xx-small) is most satisfactory, alternatively use the percentage or em scales. As you select and alter the size you can see the result directly on your page.
Text in table. Size not specified. Inherited from div. |
Size for this cell set to 120% |
Text in a second table |
Text size for table set to 120% |
Size for cell not specified inherited from table. |
When setting font sizes for text lying directly in the body element 1em, 100% and 'medium' generally yield identical results. Font sizes are inherited so text in elements which themselves sit in the body will, unless specified separately, use the same sizes. Elements may however sit, not directly in the body but, within other elements such as a table or a division. Where such a table or division has a font size set on itself this may be inherited by text within that table or division. For instance, if a div has font size set to 150% and a paragraph within the div has font size set to 1em then the text will actually be rendered at 1.5em due to it inheriting the scale from the div.
Note A division is formed using the
An example of how this can work is given in the adjacent figure. Text sits in table cells, which sit within a table which sits within a division. One of the tables and one of the cells has font size specified. Others do not.
Not all sizes scale in this way. Sizes set as a percentage or in em or ex do scale and are referred to as relative sizes. Sizes specified using the xx-small system do not scale and are referred to as absolute sizes
Note All sizes will zoom using the browser text size options with the exception of sizes specified in pixels. In this case browsers vary in response.
Font Colour. Either enter a colour into the box or click on the button to the right. If you click on the button the ‘Text Color’ window opens and you have three more options. (It’s like buying an ice cream in the USA or making a phone call in the UK.) You can specify in terms of Hue, Saturation and Brightness (HSB), Red, Green Blue values (RGB) (range 0 to 255). Alternatively click on one of the 70 boxes of colours offered.
These are so-called ‘web safe’ colours because they work on lower performance displays. Actually the full range of 216 web-safe colours is not provided but, in any case, modern displays normally work in at least 24-bit colour so there is little justification for this limitation.
The next option is to click on the rainbow type area. Whichever you choose, the selected colour appears immediately on the square. Fine adjustments may be made using the RGB or HSB values. A box labelled Hex value shows the colour as a hexadecimal number. Actually you could have done this directly without opening the ‘Text Color’ window – when you close the window you’ll see the hex value (preceded by a ‘#’) in the box along with a sample of the colour on the button.
Named colours. You might have noticed, as you clicked on one of the 70 colours, that occasionally in the box labelled ‘Name’ the name of a colour appeared. (Try black or red to check.) The CSS recommendation recognises 17 colours and the names of these can be entered directly here, or, in fact, into the selector box without entering the ‘Text Color’ window.
The 17 CSScolours and names:
Black
Gray
Maroon
Red
Orange
Yellow
Lime
Green
Teal
Olive
Aqua
Blue
Navy
Fuchsia
Purple
Silver
White
Other text options
These appear below the colour option and are fairly self-explanatory.
Colour
This is selected in the same way as for Font colour.
Image
You can specify an image file as a background. This will appear behind anything else. Under ‘Tile’, if you select ‘Don’t tile’ you get a single copy of the file which you can position with the buttons below. If you select ‘Tile’ the image repeats in the directions selected.
Warning. The opacity option uses a property not included in the CSS2 Specification, which is either not implemented or implemented incorrectly by most browsers.
Items can be bordered and the options available provide great flexibility. Styles, thickness and colours may be set independently for each side.
Note For a border to show both width and style must be specified.
The block structure in which most elements are located has already been mentioned (section 3.4.1). The Box options control the display within these blocks.
For those boxes which require a dimension to be entered: first type the number, then select the unit from the drop down box.
Margin Controls the distance between the element’s box, i.e. where any border would be, and either the surrounding box or adjacent boxes.
Note Vertical margins ‘collapse’. If a heading has a bottom margin set to 20px and is followed by a paragraph with a top margin set to 10px the separation between them is controlled by the greater (20px) not the sum (30 px).
Padding Controls the distance between the box content and its border.
Width and Height allow a specific size to be allocated to the content area of a box. This can be an absolute width or a percentage of the containing box.
Note The spin buttons beside each box allow fine adjustments to be made easily. In most cases the effect can be sen in real time on the screen.
Float allows blocks to be treated rather like images and to float them to the right or left hand side of a page (or to the edge of the enclosing block). Other elements may therefore appear to wrap around them.
Position, Offset and z-index are parameters related to the use of layers. These have been covered in section 3.10.6
Instead of setting styles for one element at a time it may be easier to specify several at the same time. Perhaps all your headings are in one font (e.g. serif) and all others in an other (sans-serif). You can specify h1, h2, h3, h4, h5 and h6 as serif font in a single action. When you create a style rule at step, 4 instead of entering the tag for one element, just list all required and separate the tags by commas. Later you can specify, for example the size of, each heading individually in a separate rule.
EDITING SELECTORS
If you have already set up the style declarations required, perhaps for h1, but now want it to apply to additional elements just click the `Edit selector’ button above the `Sheets and rules’ pane and type in the additional tags separated by commas.
Tip: Class names can contain letters, digits, hyphens and underscores but not spaces and must not start with a digit or a hyphen followed by a digit. They are case insensitive. N.B. Class names do not include the initial dot.
I’ve suggested above that you start by applying styles to all elements of a specific type. Such style definitions will apply automatically wherever that element is found on a page. This provides for great consistency within a document but maybe a touch of dullness! You can also define your own styles and apply them selectively. These styles are known as ‘Classes’.
Using Nvu – To create a class
To create a class
Now proceed as in section 4.2.1 ‘To define how you want elements to look’. In that case you could watch the effect of your styles appear immediately on your page (assuming that you had a page which used the corresponding elements). Now, of course, you have none, so first we must learn how to apply a class to an element.
First enter some details for your new class that will allow you to recognise it on the screen if it is applied. For instance use the border tab to produce a border styled as solid, 2px wide, coloured red.
It is possible to set styles for several classes at the same time just as it was for elements. Proceed as in 4.2.2 but precede all class names by a dot e.g. .style1, .style2
(KompoZer automatically adds the dot for the first).
KompoZer provides two methods for applying classes. Method 1 is the simpler; sometimes it is difficult to select the item to use this method in which case method 2 is preferable.
Apply a class - Method 1
Note Although KompoZer is not a browser it replicates the browser display very well. However styles applied to links are not rendered correctly.
Apply a class - Method 2
Note This mode cannot be used to create the span element needed to style an inline section of text but can style such a section once the span exists.
Once a class has been attributed to an element it is shown on the the tag on the status bar.
Note Elements can actually have several classes applied. If you do this you should ensure that the class properties don’t conflict with each other. Most people will probably prefer to apply only one class at a time. You may need to check that you don’t apply more by mistake.
A similar procedure may be used to disconnect an element from a class. Using the highlighted tag method simply select the ticked class, this deselects it. Using the class selector box select the style again, this should cancel it. Alternatively, after selecting the element, right-click on the highlighted tag on the status bar and select ‘Advanced properties’. The selected class will be listed select it and click ‘Remove’.
There are three ways to start working with external style sheets
External style sheets are created in almost exactly the same way as internal sheets.
To create an external style sheet
Now click on ‘RULE’ and you should be on familiar territory.
When we created internal styles they were entered on our page in the HEAD section. Now the styles are being created in an external file. If you looked, in ‘Source’ View, in the head area you would see a line referring to the external file and linking it to your page.
Warning – Unfortunately Nvu makes a meal of inserting the filename. It puts the absolute address of the file as it appears on your hard drive. When you upload or move your page the stylesheet won’t be found. You will need to edit the HTML Source code in the line starting (note the ‘line’, which may spread over several lines, finishes
type="text/css">
) Delete all the code like file:///C:/Documents%20
… right up to and including the / before the filename. The result should contain text like href="filename.css"
. If your stylesheet is in a sub-folder the text should be like href="subfolder/filename.css"
.
If you already have set up your page using internal styles you can convert them into an external stylesheet and link to that.
Open the CSS Editor. In the ‘Sheets and rules’ pane click on the stylesheet and under the general tab click on ‘Export stylesheet and switch to exported version’ and proceed.
If you have a stylesheet that you created for another page or intend to use right across your site you can link your page to that.
To link to an existing external style sheet
You can now close the CSS editor, but, of course you can work on the stylesheet in the usual way.
NB the same warning applies as in section 4.2.4.1
External style sheets are created in almost exactly the same way as internal sheets.
To create an external style sheet if the file has no internal or external stylesheet.
Once the sheet has been created you may use it to store any style rules that you wish.
When we created internal styles they were entered on our page in the HEAD section. Now the styles are being created in an external file. If you looked, in ‘Source’ View, in the head area you would see a line referring to the external file and linking it to your page.
If you already have set up your page using internal styles you can convert them into an external stylesheet and link to that.
Do this
If you have a stylesheet that you created for another page or intend to use right across your site you can link your page to that.
To link to an existing external style sheet
You can now close the CSS editor, but, of course you can work on the stylesheet in the usual way.
Once you edit a stylesheet in KompoZer its name is marked by a red symbol indicating that it has not been saved. When you close CaScadeS changed sheets are saved immediately.
Warning If the sheet is linked to several pages, any others which are open at the time will not recognise the change until they have been closed and re-opened. (File > Revert)
Element styles (section 4.2.1) and named classes (section 4.2.3) are the two main ‘selectors’ used for styles. A selector may be thought of as the link which attaches a particular style declaration to a particular item on a page.
Note Strictly the class selector consists of the class name and a prefixed dot.
In addition to these the CSS specification provides a large range of more complex selectors most of which lie outside the scope of this Guide. For details see the CSS Specification section 5. (See appendix 2.) There are however a few cases which are needed more frequently and for less complex sites and these are covered in the next two sections.
Browsers render links in default colours and provides some options for controlling these (see 3.7.1.6). Through the use of styles full control of each state of a link is possible. This is achieved through the use of selectors called link ‘pseudo-classes’.
The more important pseudo-classes are
Selector | Descripton |
a:link |
for all links not yet visited |
a:visited |
for links that have been visited |
a:hover |
for a link over which the cursor is hovering |
Note The following procedures are based on the use of internal style sheets. Very similar procedures may be used with external stylesheets.
To create link pseudo-classes
It is now possible to style these options fully, i.e. not only with text colour and decoration but with background, boxes, the lot.
Note that the a:hover
must be placed after the a:link
and a:visited
rules, since otherwise the cascading rules will hide the a:hover
rule.
To create link pseudo-classes
It is now possible to style these options fully, i.e. not only with text colour and decoration but with background, boxes, the lot.
Note that the a:hover
must be placed after the a:link
and a:visited
rules, since otherwise the cascading rules will hide the a:hover
rule.
The CSS editor enters styles in the order encountered. The order may be altered by selecting an item and clicking the ‘Up’ or ‘Down’ button.
Note These styles will now be applied to links automatically. They do not have to be applied manually as do classes.
Setting up forms to appear as required may require styles to be set for specific controls. These are set exactly as just described for links it is merely necessary to set styles for the required selectors. Some of the main ones are listed following.
Control | Element | Selector |
---|---|---|
Submit button | Input | input[type=submit] |
Reset button | Input | input[type=reset] |
Text input | Input | input[type=text] |
Text area | textarea | textarea |
Label | label | label |
Field set | fieldset | fieldset |
Legend | legend | legend |
Ids (or Unique identifiers) haven’t been mentioned so far.
Since an id is a unique identifier it can be used once only (on any page). Most commonly ids are used in conjunction with the div element to mark a particular area on a page such as a table of contents, a menu or some such. It is helpful in such cases to give the id a name which indicates its use.
To create a style based on an ID
#menu
.To apply an ID
While, in principle, ids are similar to classes it is not possible in Nvu to apply an id via the class selector box but the method is still easy.
Tip: id names may use the same characters as class names.
To create a style based on an id
To apply an ID
While, in principle, ids are similar to classes it is not possible to apply an id via the class selector box but the method is still easy.
Warning You can apply each id only once on a page. KompoZer at version 0.7.10 will ensure that this occurs however if you apply an id that is already in use no warning is given and the id will be applied as requested with the first instance being removed.
CaScadeS allows you to remove styles in a similar way to adding them.
In the ‘Sheets and rules’ pane select the rule you want to remove and click ‘Remove’ .
Similarly you can remove a stylesheet. Select the sheet and click ‘Remove’. If you select an internal stylesheet it is deleted from the file completely.
Warning this deletion is not reversible using ‘Undo’.
If you remove an external stylesheet the link on the page is removed. The external file is left intact and can be re-linked if required as described in section 4.2.4.3.
A web page has a hierarchical structure e.g. text in a table cell sits under the ‘Table’. You see some of this structure in ‘HTML Tags view’.
Inheritance means that style properties set at a high level in the structure e.g. at ‘Body’ level will be applied at lower levels unless specifically re-specified. So a font family set the ‘Table’ element will be applied to everything in the table but if you include a paragraph in the table and set a different font for the ‘p’ element then that will be applied. Section 4.2.1.1 has already shown a small demonstration of the effect.
Inheritance is very useful as it allows properties to be set once in a style sheet rather than having to be applied to every element that you want to use that property.
You will have to consult a detailed specification (such as appendix F ‘Full property table’ of the CSS2.1 specification) to see what is inherited and what is not but, in general, you can assume that all properties are inherited except things like Background, Border, Margin, Padding, Width and positioning.
The
To create a div
It is now possible to insert any desired item into the div e.g. Text or images. Text may then be selected and formatted as paragraphs etc. If required, divs may be inserted so that a set of nested divs is produced.
Sometimes difficulty may be experienced such that elements in a div disappear when an attempt is made to populate them. To avoid this, it is undesirable to insert empty elements, so either insert, for example, one paragraph at a time or enter some dummy text as a placeholder.
To apply a class to a div
Proceed in the normal way (see section 4.2.3.1). The class selector box may be used to apply a class to a div but it will not display the class which has been set. The preferred method to use is via the highlighted tag on the status bar which can be used to add or remove classes
To inspect or change a class
Use the status bar to access the class.
Elements within a div may have styles applied in the all the normal ways.
Tip: If you do get ‘trapped’ in the last division on page need to work between two touching divs in the flow there is a way to escape. Click on the last item in the division and then on the marker for the div on the status bar. Next press the down arrow key. This will take the pointer to below the div though the cursor will not be visible.
You can use the same technique to escape from other block elements.
To leave a div
Click in any area outside the div. This is why a div should never be the last item on a page it will be impossible to leave it except to visit an item higher on the page.
Unique divisions
A common use of divs is for unique regions of a page. Examples might be a menu, a table of contents or the main text area. In such cases rather than applying a class to a div it is more appropriate to use an 'id'.
A div is a useful way of applying a different set of styles within a limited region on a page. Of course a set of classes could be designed and applied to the elements within the region but this is laborious and bloats the code. A simpler way is to establish a set of styles for the elements in the div and to tag them in such a way that they apply only within the div. This is done using an appropriate selector. Suppose the div has a class ‘divclas’. Examples of appropriate selectors are:
div.divclas p
div.divclas td
div.divclas a:visited
Or when using ids
#menu p
#contents li
These may be set up in the same way as for pseudo-classes see section 4.2.5.2.
In section 3.10.3 we noted that ‘Layers’ are contained in ‘divs’. In fact a layer is simply a div which has a position, and optionally a z-index, style attached. When KompoZer creates a layer it does so by attaching an inline style to the div.
It is equally possible to create a layer by setting up an appropriate class and attaching this to a div.
When a layer is created in this way KompoZer depicts it as a normal layer and renders it with a surrounding box with sizing and position handles. Visually it is indistinguishable from any other layer.
Such layers may, of course be precisely located and are not subject to the vagaries of manual dragging.
Warning If a layer, created using a class, is subsequently dragged or resized, KompoZer attaches an inline style. Any styling so added will override the class styling.