|
|
||||||||||||||
Creating style sheetsThe reasons for the introduction of style sheets and their advantages were described in the introduction to style sheets topic. This tutorial will teach you how to create your own style sheets. How to define style sheetsTo begin with, let's take a look at the webpage code below that does not have a style sheet:
Copy and paste the above code into a new document, and preview it. As you can see, the heading is at the standard H1 size. Now replace the code in the document with the code below:
When you preview the webpage, you will see that the size of the heading is significantly larger than when the first code was used. The size of the heading was changed as a result of the style sheet specification. As you can see, the style sheet information was defined between the The style sheet definition should be placed within the header of the document, between the Supporting older browsersBecause older web browsers may not understand style sheets, and might mistaken them for webpage content, you can use HTML comment tags. This hides the style sheet information from older browsers. The example below shows how to do this.
Defining multiple propertiesMore than one style property can be defined for each element by separating each with a semi-colon (;). For example, the following code sets the size as well as the colour for a paragraph element.
Linking to an external style sheetThe advantages of style sheets become even more apparent when they are used as "external" style sheets. This is a separate file that contains your style definitions. To link a webpage to an external stylesheet, simply add the element inside the page header:
The style sheet file you create, filename.css, would contain each style sheet definition. It does not contain any HTML elements. The code below is an example of text that could be written in the file:
When saving an external style sheet in the BestAddress HTML Editor, simply choose style sheets from the save as type list when saving the file. Where to from here?The principal of using style sheets is relatively simple. Style sheets, however, support many different properties. For more information on the various styles available, we recommended that you refer to the BestAddress HTML Editor's style sheet online reference guide. |
||||||||||||||
![]()
A Multimedia Australia website.
Copyright © 2001 - 2010 Multimedia Australia Pty. Ltd.
Australian Company Number 096 830 394. All rights reserved.
ABN 78 096 830 394
Terms of use. Disclaimer. Privacy Statement.