| home / authoring / languages / xhtml / beginning / chap13 / 3 |
[previous] |
|
Try It Out - Applying Margins to the Body ElementIn this exercise, we will apply the margin property to the body element. We would like to be showing you how to apply margins to the @page rules, but since they don't currently work in the major browsers, this is the next best approach.
How it WorksIn Step 1, we described how we wanted the document to print by specifying three @media rules. If you look at the third @media rule:
We can see that we specified that the left margin and right margin should be 3 centimeters. Notice that we did not assign these properties in the @media rules for the screen media type or the shared screen and print media rules. This means that the margins will only be seen when the document is printed. In Step 2, we associate the style sheet with our document, and in Step 3 we load the document into Microsoft Internet Explorer. As you can see in Step 3, there is no hint of a margin. This is because we did not specify any value for the margins for the screen media type in Step 1. In Step 4, we print the document and the margins appear; this is because we specified margins for the print media type in Step 1. The 'marks' PropertyYou use the marks property to display crop marks and cross marks on the printed page. Crop marks indicate where the paper should be cut; this is important when you print a document on a page that is larger than the target page size. Cross marks are used so that multiple pages can be aligned. To show crop marks, we write:
and to show cross marks, we write:
If you do not want to show any marks (which is the default), we write:
Since crop and cross marks appear outside of the normal page area, they can only be seen if you set your page size, using the @page rule's size property, to an absolute value. Naming @page rules and the page propertyAs mentioned earlier, the @page rules can be applied to the entire document by writing:
to left hand pages by writing:
and to right hand pages by writing:
In addition, you can name @page rules so that you can apply them with greater fidelity. To name an @page rule, you write:
where name is replaced with the name of your rule. For example, if you wanted to write an @page named 'rotated' that forced an element to appear in landscape mode, you would write:
This named @page rule can then be applied to an element by using the page property. For example, if you wanted all tables to appear on paper in landscape mode, you would write:
This means that all tables will appear on pages that are printed in landscape mode. If it happens that the page containing the table is being printed in a different mode, a page break will be inserted before the table, forcing the table to appear on a new page printed in landscape mode. Unfortunately, as mentioned before, the @page rules are not currently supported in the major browsers, so we do not have the chance to use these properties in practice! |
| home / authoring / languages / xhtml / beginning / chap13 / 3 |
[previous] |
Created: April 19, 2001
Revised: April 19, 2001