Download A guide to HTML the HyperText Markup Language

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

URL redirection wikipedia , lookup

Transcript
Reference
: USER 009
Issue Date
: September2005
Classification
: Web
Originator
: Derek Sheward, Claire Napier
REVISED DOCUMENT
A guide to HTML – the HyperText Markup Language
•••••••••••••••••••••••••
Description:
This document provides an introduction to the HyperText Markup Language (HTML)
to produce simple scripted pages for the web. The user will need a background knowledge
of Internet Explorer® or similar web browsing software and a basic understanding of how
to create plain text files from a text editor or word processing package.
If you have any queries:
Students should contact the nearest Information Services, Student Help Desk.
Student Help Desks are located within the:
IT Learning Centre - Brindley
IT and Library Help Desk - Thompson Library
IT Learning Centre - Octagon
Staff should contact Information Services on x3800.
More guides and information can be found on the Information Services web pages at:
http://www.staffs.ac.uk/uniservices/infoservices/documents/
If you do not find what you want please ask at the Student Help Desk.
D.R.Sheward/C.L.Napier/Jan-08
1
What is HTML?
HTML (HyperText Mark-up Language), is the standard language
used to
create web pages.
It offers basic text formatting - from italicising, emboldening etc.,
through to creating lists, in-line graphics, and the ability to link to
other HTML pages, movie files, pictures, sound files, software
archives and more.
You can create HTML using a word processing package, but you
need to save the file as text only. If it is saved as an ordinary
Word® document, the Web Browser won’t display it.
Getting your pages on the web
To get your pages on the web, you need to put your files on a web
server, which is essentially a large computer that is connected to
the Internet. When you want to view a page on the Internet, your
computer connects to this server and the appropriate pages are
then downloaded to your web browser.
To view pages that you have created on your own computer, you
don't need to put them on a web server, you can view them by
opening them from your web browser.
Getting started
If you are using Windows®, create your HTML files using WordPad®.
Click Start; Programs; Accessories; WordPad®
If you are using an Apple Macintosh, create your HTML files using
SimpleText®.
Your choice of font and size in the word processor has no effect on
its appearance on the web, nor will the use of tabs or extra blank
lines. All “white space” in an HTML file is treated as a single
character (unless the preformatted text option is used).
HTML itself is not case sensitive but there are certain rules that you
can follow:
- any text written in capitals between tags will be displayed as
such in the browser.
- references to file names are case sensitive.
Laying out your HTML
-
Include plenty of white space around your HTML – it makes it
easier to read.
Type your tags in capital letters so that they stand out
from the rest of your text.
Use indents so you can see where tags begin and end.
<HTML>
<HEAD>
<TITLE>HTML exercise</TITLE>
</HEAD>
<BODY>
D.R.Sheward/C.L.Napier/Jan-08
2
<H2>Introduction</H2>
This is my first web page.
</BODY>
</HTML>
Saving your HTML file
Your must save your HTML file from a word processor in the 'Text
Only' format, and attach .htm or .html as the file extension. E.g. if
you wanted to call your file 'welcome' type in welcome.htm or
welcome.html
1. From the File menu of your word processor, choose Save As…
2. From the list of available file types, usually at the bottom of the
Save As box, choose Text Only.
Note: With SimpleText® on Apple Macintosh computers, Text
Only is the only format you can save files in, so you won't see an
option to choose Text Only.
3. Name your file using lowercase text without spaces, and put the
.htm or .html on the end of the file name.
File names and addresses are case sensitive and it’s best
sticking to lower case, otherwise anyone typing the address into
a web browser has to remember to the upper and lowercase
text, and it's easy to get wrong.
Tips when choosing file names
When choosing your file names, don't put spaces in file names. If
you wish to make a distinction between words, separate them with
an underscore (_) or minus sign (-) character. Do not use any other
special characters in file names, and especially do not use slashes
(/).
Web servers have reserved file names for documents that it will
show first – e.g. welcome or index. Find out the reserved name for
the server that you are using and use that name on the page you
want viewers to see first.
Previewing your work
Open Internet Explorer®.
From the File menu, choose Page…
Click Browse… and locate the file you want to open.
Click Open then click the OK button.
The Browser will display the file as it would be seen on the
World Wide Web.
If isn’t displayed quite as you had hoped, or not displayed at
all, open the file in your word processor and check your HTML
to make sure that there aren’t any spelling mistakes or missing
tags.
5. Save any changes or additions, making sure the file is 'text
only' and go back into Internet Explorer, click the Refresh
button, to reload the new version of your file.
Edit your page in this way until you are happy with the result.
1.
2.
3.
4.
The basics of HTML
D.R.Sheward/C.L.Napier/Jan-08
3
The information, e.g. text or linking information, appearing on your
web page is contained between tags - a left and right angular
bracket,
<H1>Hello world</H1>
How that information is actually displayed on the web page depends
which HTML tags were used to enclose the information.
Some tags come in pairs, the first to start off the formatting, <H1>
the second to terminate it </H1>.
Paired tags, usually surround pieces of text or in-line images, and
have an effect on that enclosed text or image. Termination tags
have a slash / after the first bracket </>
Standalone tags are used when a single, one-off effect is required,
for example <HR> to insert a horizontal rule, or <BR> to insert a
line break.
The HTML tag <HTML> </HTML>
This is the first and last tag you will use in your HTML document. It
tells a web browser that the document it is about to use is written in
HTML.
Your HTML document is placed between these tags.
<HTML>
your document goes here…
</HTML>
Header tag <HEAD> </HEAD>
The header tags, not to be confused with the heading tags, are
where the browser looks for information about your document. Your
document title goes between the head tags.
<HTML>
<HEAD>
</HEAD>
</HTML>
Title tag <TITLE> </TITLE>
The Title tags are inserted between the head tags. Place your
document's title between these tags where it will appear in the title
bar of the browser window. It is important to use something short,
memorable and indicative of your page’s content.
It doesn’t have to be the same as the HTML file name.
<HTML>
<HEAD>
<TITLE>Introduction to HTML</TITLE>
</HEAD>
</HTML>
Body tag <BODY> </BODY>
Between these tags is where you start constructing the actual page.
This is where all the details about your page are contained, such as
text, pictures and even details about colours.
<HTML>
<HEAD>
<TITLE>Introduction to HTML</TITLE>
D.R.Sheward/C.L.Napier/Jan-08
4
</HEAD>
<BODY>
web page goes here
</BODY>
</HTML>
Adding text to a web page…
Heading tags <Hx> </Hx>
There are six types of heading, numbered Hl (largest) through to H6
(smallest). The format of the heading tag is: <Hx>Your
heading</Hx>, where x is the number of the heading, 1 through to
6
D.R.Sheward/C.L.Napier/Jan-08
5
<H1>Heading1</H1>
<H2>Heading2</H2>
<H3>Heading3</H3>
<H4>Heading4</H4>
<H5>Heading5</H5>
<H6>Heading6</H6>
Example of a heading tag used inside an HTML document…
<HTML>
<HEAD>
<TITLE>Introduction to HTML</TITLE>
</HEAD>
<BODY>
<H1>Introduction</H1>
</BODY>
</HTML>
Paragraph tag <P> </P>
The paragraph tag is used to signal the start and end of a
paragraph. They can be preceded by a heading or even contain one.
<HTML>
<HEAD>
<TITLE>Introduction to HTML</TITLE>
</HEAD>
<BODY>
<H1>Introduction</H1>
<P> This is the text and the main content (Body) of the
HTML page. This is one paragraph.</P>
</BODY>
</HTML>
Line breaks
The web browser will automatically word-wrap text to enable it to fit
the screen on which it is being displayed (unless the text is
preformatted).
Spaces or line breaks in an HTML file (in your Word processing
package) are not automatically translated into spaces or line breaks
by the Web Browser. A line break will only occur when a paragraph
ends and a new one begun or a forced line break tag is reached.
Forced line break tag <BR>
The <BR> tag will force an immediate line break with NO
ADDITIONAL blank spaces between lines. To insert several blank
lines use multiple tags e.g. <BR><BR><BR>. The <BR> tag is one
of a few HTML tags that doesn't require a corresponding closure tag
e.g. </BR>.
The example below breaks the text 'This is one paragraph' onto a
new line.
D.R.Sheward/C.L.Napier/Jan-08
6
<P> This is the text and the main content (Body) of the HTML
page.<BR>
This is one paragraph.</P>
Note it’s a good idea to put the text on a new line so you can
easily see, when reading the HTML, where the line break is
Horizontal rule tag <HR>
The <HR> tag inserts a 3D horizontal rule across the width of the
screen.
Like the <BR> the <HR> tag does not have a corresponding
termination tag.
<HTML>
<HEAD>
<TITLE>HTML exercise</TITLE
</HEAD>
<BODY>
<H1>Three blind mice</H1>
<P>Three blind mice, <BR> Three blind mice.</P>
See how they run, <BR> See how they run
<HR>
</BODY>
</HTML>
This produces…
Formatting tags
There are a number of tags available that alter the appearance of
text.
Tags…
<VAR>Variables</VAR>
<EM>emphasis</EM>
<CITE>Citation</CITE>
<STRONG>strong</STRONG>
<ADDRESS>Address</ADDRESS>
<I>italic</I>
<B>bold</B>
<U>underline</U>
<STRIKE>Strikethrough</STRIKE>
D.R.Sheward/C.L.Napier/Jan-08
7
Results…
Note: be aware that using the <U> tag suggests that the text is
a hypertext link, so where possible, avoid using it.
These tags can also be combined…
<B><I>Bold italic</I><B>
Note: the opening and closing tags should be nested correctly,
the first tag used should be the last one to be terminated e.g.
<B><I>text</I><B> not <B><I>text</B></I>.
The following styles use a non-proportional font, such as Courier or
VT100.
Tags…
Result…
<PRE>h e l l o</PRE>
<SAMP>Sample</SAMP>
<CODE>Coded</CODE>
Blockquote <BLOCKQUOTE> </BLOCKQUOTE>
Blockquote will put all enclosed text into a paragraph, and will
indent the whole paragraph by one step. This is useful for verse etc.
There is no need to use the paragraph tags if <BLOCKQUOTE> is
being used.
<H1>Introduction</H1>
My first nursery rhyme
<BLOCKQUOTE>Three blind mice, Three blind mice, See how
they run, See how they run...
</BLOCKQUOTE>
Now for the second part.
Produces…
Font size <FONT SIZE=1> </FONTSIZE>
D.R.Sheward/C.L.Napier/Jan-08
8
You can change the size of text by using the font size tags text and
entering a number from 1 (smallest) to 6 (largest).
Note: this is the total opposite to the numbering system used for
headings.
<FONT
SIZE=1>Fontsize1</FONTSIZE>
<FONT
SIZE=2>Fontsize2</FONTSIZE>
<FONT
SIZE=3>Fontsize3</FONTSIZE>
<FONT
SIZE=4>Fontsize4</FONTSIZE>
<FONT
SIZE=5>Fontsize5</FONTSIZE>
<FONT
SIZE=6>Fontsize6</FONTSIZE>
Aligning headings
Whereas pressing the Tab or Space keys moves text across the
page in a word processing package, it won't be recognised in HTML.
You have to use the ALIGN attribute along with the tag of the object
your want to align. Headings, paragraph text and images can all be
aligned using the ALIGN attribute.
For example:
<H1 ALIGN=left>your heading</H1>
aligns the heading to the left of the page
<H1 ALIGN=center>your heading</H1>
centralises the heading
<H1 ALIGN=right>your heading</H1>
aligns the heading to the right of the page
Creating Hyperlinks
The whole principle of HTML is to provide the user with links to go
“somewhere else” at the click of a button. The link can be text or an
image and the “somewhere else” is not necessarily more text on
another page, but may be an image, sound, movie, or information
database, somewhere else on the World Wide Web.
A hyperlink consists of two components;
- the object that the user clicks on,
- the resulting destination once the link has been selected.
Anchor tags <A> </A>
The anchor tags are used to create a link, and can be formed
around text or an image.
You need to specify what or where you are linking to, and what has
to be done when the Web Browser goes to it.
D.R.Sheward/Jan-08
9
<A HREF="destination">link text</A>
The 'destination' can be;
- a file name of a different web page on the same site,
- a web address (URL) to link to another web page,
- a named item (text or image) within the same HTML document.
This named item is referred to as a Named Anchor or Target.
The text 'link text' in-between the tags, is where you add the text
that forms the clickable link.
<A HREF="http://www.staffs.ac.uk">Staffordshire
University</A>
The above example would make the text ‘Staffordshire University’ a
link to a web address, http://www.staffs.ac.uk. This is the address
for the University's home page.
The link tags can be placed around paragraph text as you obviously
don't want the whole paragraph to be a hyperlink - one or two
words are usually sufficient.
<P>Click <A HREF="http://www.staffs.ac.uk">here</A> to visit
Staffordshire University's home page.</P>
would produce…
D.R.Sheward/Jan-08
8
Specifying a path through folders (directories)
<A HREF="index.htm">Home</A>
In the above example, clicking 'Home' would link to a file called
'index.htm' stored at the same level (same folder) as the page
containing the link.
If the page you are linking to is located in a different folder to the
one you are linking from, the link will need to contain the names of
the folder and the page.
Going down a level
To link to a page contained in a folder that is in the same folder as
the page you linking from, e.g. to link from a file called 'details.htm'
to one called 'index.htm' stored in a folder called 'front',
the link would be…
<A HREF="front/index.htm">Home</A>
Going up a level
Using the example of 'index.htm' being inside the 'front' folder, but
this time the page containing the link is itself stored in a folder, e.g.
called 'details'.
The hyperlink would need to tell the web browser to come out of the
current folder 'details' and then go into the 'front' folder and choose
the 'index.htm' file. The link would be…
<A HREF="../front/index.htm">Home</A>
The addition of ../ tells the web browser to look outside of the
current folder or jump a level. Each ../ tells the browser to go up a
level, so to jump up two levels the link would be…
<A HREF="../../front/index.htm">Home</A>
The Named Anchor tag <A NAME> </A>
Before you can link to a specific place in a web page you need to
define a destination by enclosing the object (text or image) with the
Named Anchor tag.
<A NAME=anchor name>text linked to</A>
The text 'anchor name' is replaced with your own anchor name that
will be used in the hyperlink that links to whatever text you select
from your document to replace 'text linked to'.
Named Anchors are often applied to headings when there is a 'table
of contents' at the top of a page.
D.R.Sheward/Jan-08
9
<A NAME=introduction>Introduction to HTML</A>
The above anchor is named 'introduction' and it is applied to the
text 'Introduction to HTML'.
Points to note about Named Anchors:
- use something identifiable for the anchor name – there are no
size restrictions and spaces are permitted.
- the name of the anchor is case sensitive. If the link doesn’t work
– check the spelling of the anchor name, making sure that you
haven’t used capitals.
- the web browser doesn’t visually indicate the location of Named
Anchors.
Creating a link to a Named Anchor on the same page
Firstly define your Named Anchor as described above, and then
create a hyperlink.
Using the following example as the Named Anchor,
<A NAME=introduction>Introduction to HTML</A>
the hyperlink you would need to create to link to it would be…
<A HREF="#introduction">link text</A>
Note: that when linking to Named Anchors, the # symbol always
precedes the name of the anchor; it tells the web browser to look
for a named anchor within an HTML document.
Creating a link to a Named Anchor on another page
To link to a Named Anchor within another page, the hyperlink would
need to locate the other page and then the appropriate Named
Anchor.
<A HREF="location #anchor name">link text</A>
If the University home page contained a Named Anchor called intro,
to link to it the hyperlink would be…
<A HREF="http://www.staffs.ac.uk#intro">link text</A>
or
To link to a Named Anchor contained on a page called 'index.htm'
stored in the same place, as the one you are linking from, the link
would be…
<A HREF="index.htm#intro">link text</A>
The 'top' Anchor
The destination 'top' has been set aside in HTML to return to the top
of the current page when the link
<A HREF="#top">back to the top</A>
D.R.Sheward/Jan-08
10
is selected.
'Top' is a reserved Named Anchor and is interpreted by web
browsers as meaning 'go to the top of the current page', and
therefore you don't need to insert your own Named Anchor.
Creating a link to an email address
You can make it easy for a reader to send electronic mail to a
specific person from a web page by including the mailto attribute
within a link.
<A HREF="mailto:YourAddress@host">text</a>
Note: there are no forward slashes in mailto: links.
For example,
<A HREF="mailto:[email protected]">Email</a>
G.Smithy
produces…
Note: to be able to send emails from a web link your web
browser settings need to be changed to give it a Mail Identity. In
Internet Explorer® this is done through Internet Options.
Using images on web pages
There are two main image formats that are used on the web, GIF or
JPG (sometimes called JPEG).
Most graphics applications, e.g. Microsoft PhotoEditor® in Windows®
will allow you to save files in one of these formats. Graphical
conversion utilities are also available.
The two formats have different characteristics and different uses:
GIF (graphics interchange format)
- Uses a maximum of 256 colours
- Lossless compression – you don’t sacrifice image quality in
return for a smaller file size
- Best used for black and white line art and thumbnails.
- Can have transparent backgrounds – without a background.
- Can be used for animations (GIF animations)
JPEG (joint photographic experts group)
- On Windows PCs the format is referred to as JPG, on a
Macintosh it's JPEG.
- Can use up to 16.7 million colours
- Good for high quality colourful images, such as photographs
- Lossy compression – sacrifices image quality in return for
smaller file size. (Providing that you set the compression setting
to high or best image quality the loss in image quality will be
largely unnoticeable.)
D.R.Sheward/Jan-08
11
Using images on your web doesn't actually put the image onto the
page; the tags act as a placeholder that refers to an image file.
Whatever image file is referred to will appear on the page, if the file
is missing then the image won’t be displayed on the page and a
missing page icon will be displayed.
If the viewer has turned off image loading or an image is
unavailable, the web browser will usually display an image
p1aceholder where the graphic would be.
If you see an image placeholder when you are previewing your
page, check that images are turned on in the browser and that you
typed the HTML and filename of the image correctly.
Image tag <IMG SRC=”name of image file”>
To insert an image in your web page, use the image tag as shown
below…
<IMG SRC=”triangle.gif”>
It's considered good practice to keep any images used on your web
pages in a directory separate from your HTML files, so that all files
of the same type are kept in the same place. This directory is
commonly called 'images'.
The tag for inserting a triangle image from the images directory
onto the index.htm page would be…
<IMG SRC=”images/triangle.gif”>
Small images such as triangles or dots are commonly used
alongside text to highlight a list item.
<IMG SRC=”images/triangle.gif”>Introduction
This would produce…
Aligning images <IMG ALIGN=alignment type SRC=“image file”>
Like text, images can be aligned left, right or centrally on a web
page.
<IMG ALIGN=right SRC= “filename.gif”>
Images can also be aligned to the top, middle and bottom of any
line of text. By default, the image bottom is aligned with the text.
D.R.Sheward/Jan-08
12
<IMG ALIGN=top SRC= “filename.gif”>
<IMG ALIGN=middle SRC= “filename.gif”>
<IMG ALIGN=bottom SRC= “filename.gif”>
Alternative image description – ALT text
Alternative image description (ALT text) offers the viewer a textural
description of an image if the browser won’t display the image or if
a web browser has image loading turned off. The ALT text is
inserted inside the IMG tag. For example,
<IMG SRC=”unilogo.gif” ALT= “Staffs Uni logo”>
Note: It is very important to include ALT text as it is used by
screen reader software for visually impaired people.
Using images as clickable links
Combine the Hypertext reference tag with an image tag
<A HREF=”destination”><IMG SRC=”image file” ALT=”image
description”></A>
For example, to turn the image file unilogo.gif into a clickable link
leading to the University's home page, the HTML would be…
<A HREF=”http://www.staffs.ac.uk”>
<IMG SRC=”unilogo.gif” ALT=”Staffs Uni logo></A>
Images that are defined as links will display a border the same
colour as text links.
D.R.Sheward/Jan-08
13
To remove the border, insert the BORDER attribute and set the
value to zero.
<A HREF=”http://www.staffs.ac.uk”><IMG SRC=”unilogo.gif”
ALT=”Staffs Uni logo BORDER=0></A>
Linked images are commonly used when creating Thumbnails.
Thumbnails - what’s a thumbnail?
A Thumbnail is an image, small in both appearance and file size,
linked to a larger better quality version on a separate page.
Usually, the thumbnail is a 2-3k GIF preview linked to a high quality
JPEG image. This way a viewer can see a low quality version of an
image and decide whether or not to download the larger high
quality version.
Image tips
-
-
Despite being embedded on the HTML page, images still remain
as external files.
File management and site maintenance is made easier by
keeping image files in a directory separate from your HTML files.
This directory is commonly called images.
An HTML text file, even one running to a number of pages,
occupies very little disk space, and doesn’t take the web browser
long to download and display it.
Even a tiny image, say 3cm. square, will be five to ten times the
size of the HTML file, and consequently will take five to ten times
longer to download. Because of this performance problem,
viewers may turn off image loading on their web browser, or
stop downloading your page if it's taking too long.
Therefore keep the image content as low as possible within your
pages.
If you include large images, use the thumbnail technique.
Text lists
There are three main types of list in HTML:
- Bulleted list, of which there are three types: unnumbered
(unordered), directory and menu.
- Numbered list
- Glossary list
Bulleted lists <UL> </UL>
A bulleted list begins and ends with the <UL> </UL> unnumbered
list tags.
Each item in the list is inserted between the <LI> </LI> list item
tags.
D.R.Sheward/Jan-08
14
<UL>An UN-numbered List.
<LI>item one</LI>
<LI>item two</LI>
</UL>
produces this indented bulleted list…
Numbered lists <OL> </OL>
Numbered lists or Ordered lists are defined by the <OL> and </OL>
tags. As with bulleted lists, list items are placed between the <LI>
</LI> tags. List items are automatically numbered starting from
one.
<OL>A numbered list
<LI>item one</LI>
<LI>item two</LI>
</OL>
produces this indented numbered list…
To change the starting number of list items, e.g. to number from 4,
replace the <OL> tag with <OL START=new start number>
<OL START=4>Starting numbering from 4
<LI>item one</LI>
<LI>item two</LI>
</OL>
has the following effect on list numbering…
Glossary lists <DL> </DL>
A Glossary List (or Description List) encloses (descriptive) titles
between the <DT> </DT> tags and (descriptive) descriptions
between the <DD> </DD> tags.
Web browsers do not usually indent a Glossary list as they do with
other types of list, but will indent the (descriptive) description. Any
necessary text wrapping will correspond to that indentation.
<DL>
<DT>Windows XP</DT>
D.R.Sheward/Jan-08
15
<DD>Many Information Services labs now use Windows
XP.</DD>
<DD>You require a username and password to use these
machines.</DD>
<DT>Note:</DT>
<DD>From time to time, it may be necessary to change
software specification.</DD>
<DD>This list will be updated as appropriate.</DD>
</DL>
Produces…
Lists within lists
You can insert lists within lists, called Nested lists.
<UL>An un-numbered nested list.
<LI>item one</LI>
<LI>item two</LI>
<UL>
<LI>item three</LI>
<LI>item four</LI>
<UL>
</UL>
<LI>item five</LI>
<LI>item six</LI>
</UL>
</UL>
Each list item's indent will be increased by one indent more than the
previous one.
Depending on the amount of indent, unnumbered lists will, instead
of the normal black dot, display the bullet marks as dashes, filled
squares or others.
The above HTML produces the following…
You can also insert horizontal rules, paragraph and line breaks
inside lists.
D.R.Sheward/Jan-08
16
Commenting your HTML
You can add little comments to your HTML code as you can in other
programming languages. These comments will only be seen when
your HTML code is being viewed; web browsers ignore them.
<! – anything here gets ignored by web browsers - >
Special characters
Special characters always start with an ampersand (&) and end with
a semi-colon (;)
Character
<
>
&
'
©
®
meaning
HTML
less than
&lt;
greater than
&gt;
ampersand
&amp;
quote
&quot;
non-breaking space &nbsp;
copyright
&copy;
registered
&reg;
Using colour
When creating your web pages you have a choice from 216 web
safe colours, that are intended to be reproduced the same through
different browsers and different computer platforms, e.g. Windows®
and Macintosh. Using colours outside these 216, e.g. ‘non-safe’
colours will give unintended results.
Through HTML, not all colours can be applied by typing in the name
of the colour; a letter/number combination known as Hex is used
preceded by the # symbol normally refers to colours in HTML, e.g.
white is #FFFFFF, dark blue is #000066.
A listing of web safe colours and their associated Hex codes can be
found on the web.
You can set the colour of:
- body text,
- links – standard, active (when it’s clicked) and visited links
- page background colour
If you don’t specify any colours, there are standard colours a web
browser will use.
Applying colour
Colours are specified inside the <BODY> tag using the following
attributes:
- BGCOLOR for changing the background colour of a page
- TEXT for changing the colour of normal text
- LINK for changing the colour of a link before it is followed
- ALINK for changing the colour of a link when it's selected
- VLINK for changing the colour of link once its been used
<BODY BGCOLOR=”#FFFFFF”>
D.R.Sheward/Jan-08
17
would make the page background white.
Specifying a number of colour attributes at once would look like:
<BODY TEXT="#000000" BGCOLOR="#FFFFFF"
LINK="#0000EE" VLINK="#551A8B" ALINK="#FF0000">
Points to note when assigning colours
Some web browsers will change the colour links depending on the
length of time since it was last followed.
Some users may change the colours for links through their browser
from the standard colours to something else (green and yellow
maybe!). You should therefore avoid any references to the colours
of your links, as they may not be correct. e.g. don’t say “Click on
the blue text here”, for instance.
Background images – BACKGROUND attribute
Rather than using a solid colour as a background to a web page,
you can use an image. This image can be a fairly large image that
fills the browser window or a small image of a pattern that is
repeated or tiled until it fills the browser window.
GIF images are usually used for basic patterns, as they don't take
up a lot of space.
Avoid complex images or photographs as they use a lot space and
may affect the legibility of text.
Like defining colours, the BACKGROUND attribute goes inside the
<BODY> tag.
<BODY BACKGROUND="image filename">
Tips for designing pages
-
Avoid red and blue combinations, e.g. red text on a blue
background
Don’t refer to links by their colour, e.g. click the blue text
Use thumbnails where possible
Only use images if they serve a purpose.
Don’t use images for the sake of putting images on your site.
Put an email link on your page, so users are able to contact you.
Date your pages so users know how recent they are and when
they were last updated.
Where to go for more help or information
Advice is available at your nearest Student Help Desk.
Many documents are available on the web at:
http://www.staffs.ac.uk/uniservices/infoservices/documents/
There are many HTML tutorials on the web and also listings of HTML
colours.
Look at the HTML used on other peoples web pages by choosing
Source from the View menu in Internet Explorer®. This is a good
way of learning HTML.
D.R.Sheward/Jan-08
18