Creating HTML Help

Using stylesheets

Programmers who already know HTML, and use style sheets can skip this section, as it is exactly the same.

In order to ensure that all your documents are of the same style (ie all the headers are the same size and colour), you can use stylesheets. First, you need to create a stylesheet:

1) Open Notepad, and enter the text below

h1 {color:blue;font-size: 12pt;}
p {font-family: 'Tahoma';font-size: 10pt;}

2) Save the file as default.css in your html directory.

Then, enter the following html into all of your html pages. This will link the html document to the stylesheet. It is therefore a good idea to do this before you have written them all!

<link rel="STYLESHEET" HREF="default.css" TYPE="text/css">

Now, you can have a play around with the stylesheet text. First, lets look at the text we have already entered:

; the first bit: 'h1 {' means that the braces {} contain style information for all text contained in h1 tags.
; the second bit: 'color:blue;' sets the colour of h1 tags to blue
; the third bit: 'font-size: 12pt' sets the font size to 12pts
h1 {color:blue;font-size: 12pt;}

So, what's these h1 tags then, I here you ask. Well, instead of surrounding your text by p (p for paragraph) tags, like this:

<p>Hello!</p>

you use h1 tags, like this:

<h1>Hello!</h1>

It's as simple as that! In a stylesheet, you can also specify styles for:

Tag Description
h1 Header 1
h2 Header 2
h3......h6 and all headers to Header 6
p Paragraph text (the main body of your text) 
a Hyperlinks

Each 

And, inside the braces, you can use the following styles:

Style 'descriptors' Description
color Font Color
font-face Font Name (you need to contain these with a ' each side:
font-face:'Tahoma';
font-size font size. Put a pt after the value:
font-size: 10pt;
text-decoration Set to text-decoration: none; for no underline, and text-decoration: underline; for underlined text
font-weight Set to font-weight: normal; for regular, and font-weight: bold; for bold text

For more information, click Help Topics on the Help menu, and enter Cascading Style Sheets, and click HTML Tag Reference, and open the CSS book in the contents pane.

Any queries, or if you have a better way to describe this, please contact me.

You might also like...

Comments

About the author

James Crowley

James Crowley United Kingdom

James first started this website when learning Visual Basic back in 1999 whilst studying his GCSEs. The site grew steadily over the years while being run as a hobby - to a regular monthly audien...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“A computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are, in short, a perfect match” - Bill Bryson