Docsity

Handout 2.1 - Getting started with HTML, Lecture notes of Web Design and Development

Toggle sidebar
bg1
By Kimani Njoroge Page 1
HTML
Getting Started with HTML
Introduction
Refer to the HTML Handbook 1.0.0. pdf previously provided and read the contents of Lesson One
Creating an HTML document
1. Open notepad
2. Save it with a name of your choice but add .htm or .html suffix
3. Identify a folder that you will save all your documents related to the project are starting now.
NOTE:
1. Make sure you are versant with the browser your computer has. If it has more than one, select a
default one and open all your files using it.
2. When you design a website, generally you have a "home page" plus other pages that are linked to
this home page. A home page is then your main page that contains information about you, your
business or organization, plus a menu of choices for linking to your other pages or to other
websites. Most, if not all companies and organisations that provide internet services strongly
encourage their clients who want to set up a Home Page to name it index.htm or index.html. If
you plan to have other pages connected to your home page, you can give it any name you like and
with either the .htm or .html extension. But for the main home page, it should be index.htm. The
reason for this is that index.htm is the default name for most home pages online. This means that
if someone is visiting one of your other pages, and would like to see your home page, all they
have to do is erase the file name in the address location line, press the ENTER key, and your
home page will be displayed. If you don't name your home page index.htm, the browser will not
be able to locate your home page and the viewer will receive an error message. The same is true if
you are visiting another web page anywhere on the World Wide Web (WWW).
For example, let's suppose one address from a web page is:
http://www.egerton.ac.ke
http://www.safaricom.co.ke
http://www.google.com
Loading your HTML document into the browser
Once you have saved your HTML file or document, you need to SWITCH over to your browser
which is running in the background. On the browser, go to File menu and select Open ... or Open File
... or Open File in Browser ... (depending on the browser you are using). You will then need to locate
your file, click on the file name and then click the Okay button. Your HTML file will appear in the
browser. You can only observe your file in the browser - you cannot edit in the browser. Once you
have seen how your HTML file looks in the browser, you can then SWITCH back to NOTEPAD to
continue working and editing.
UNDERSTANDING THE BASIC TAGS
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Handout 2.1 - Getting started with HTML and more Lecture notes Web Design and Development in PDF only on Docsity!

HTML

Getting Started with HTML

Introduction Refer to the HTML Handbook 1.0.0. pdf previously provided and read the contents of Lesson One

Creating an HTML document

  1. Open notepad
  2. Save it with a name of your choice but add .htm or .html suffix
  3. Identify a folder that you will save all your documents related to the project are starting now.

NOTE:

  1. Make sure you are versant with the browser your computer has. If it has more than one, select a default one and open all your files using it.
  2. When you design a website, generally you have a "home page" plus other pages that are linked to this home page. A home page is then your main page that contains information about you, your business or organization, plus a menu of choices for linking to your other pages or to other websites. Most, if not all companies and organisations that provide internet services strongly encourage their clients who want to set up a Home Page to name it index.htm or index.html. If you plan to have other pages connected to your home page, you can give it any name you like and with either the .htm or .html extension. But for the main home page, it should be index.htm. The reason for this is that index.htm is the default name for most home pages online. This means that if someone is visiting one of your other pages, and would like to see your home page, all they have to do is erase the file name in the address location line, press the ENTER key, and your home page will be displayed. If you don't name your home page index.htm, the browser will not be able to locate your home page and the viewer will receive an error message. The same is true if you are visiting another web page anywhere on the World Wide Web (WWW).

For example, let's suppose one address from a web page is: http://www.egerton.ac.ke http://www.safaricom.co.ke http://www.google.com

Loading your HTML document into the browser Once you have saved your HTML file or document, you need to SWITCH over to your browser which is running in the background. On the browser, go to File menu and select Open ... or Open File ... or Open File in Browser ... (depending on the browser you are using). You will then need to locate your file, click on the file name and then click the Okay button. Your HTML file will appear in the browser. You can only observe your file in the browser - you cannot edit in the browser. Once you have seen how your HTML file looks in the browser, you can then SWITCH back to NOTEPAD to continue working and editing.

UNDERSTANDING THE BASIC TAGS

In this section we will study the HEAD, TITLE and BODY container elements and we will learn about these tags (most people still refer to "elements" as "tags") by studying the following HTML document. It is good to be actively involved in each lesson, so please start up NOTEPAD, and type in the following HTML web page. After you have typed it in, save the document using any suitable name (such as RIDDLE.HTM), and then go to your browser and load the document into your browser to see the results as they should be (given below the document).

Here is the web page. Please type:

WEB PAGE DESIGN - BASIC TAGS

Hi, my name is Wycliff Oparanya.
This is my first attempt at a Web page. Here is a riddle for you.

What is between “YOU”?

Definitely “O”.

Now when you load this document into your browser, you should see the following on the screen: Hi, my name is Wycliff Oparanya. This is my first attempt at a Web page. Here is a riddle for you.

What is between “YOU? Definitely “O”

Now for a discussion on this HTML document. Line 1 of what you typed in () tells the browser that what follows is an HTML document, and the last line () tells the browser that the HTML document is finished. Line 2 () is a new tag which we will now take a look at this tag.

** and tags** Each page of your web pages should have these tags. Statements (or tags) that give information to a person visiting your website, or information such as those needed for a Search Engine are placed between the and tags. Thus the HEAD part of a document provides information about the document. You do not see this information displayed on the browser screen. It can be seen by choosing DOCUMENT SOURCE from the VIEW menu of your browser.

Line 4:

Why did the lobster blush?

Line 5: Because it saw the salad dressing.

What is displayed on the browser:

Hi, my name is John Gilson. This is my first attempt at a Web page. Here is a riddle for you.

Why did the lobster blush? Because it saw the salad dressing.

Discussion Notice the
at the end of line 1. It simply tells the browser to drop down to the next line. The tag at the end of line 2 placed the first line across the page. Notice that the tag does not place any blank lines (empty rows) above or below the Horizontal Rule.

Problem 2: Why is the

tag at the beginning of line 4 ("Why did the lobster blush?") and not at the end of line 3 ("Here is a riddle for you.")? The second line across the page was placed by the

tag at the end of line 4. At line 5, the first
tag tells the browser to go to the beginning of the next line. The second
tag again tells the browser to go to the beginning of the next line which in effect places a blank line on the screen. The tag then placed the line across the page.

Problem 3: One

has the same effect as two
tags since the

tag forces a blank line before continuing on. Why then did I not simply use one

tag instead of two
tags at the end of line 5?

Problem 4: What does HR stand for in

?

Problem 5: Do all tags require a beginning and an ending tag?

Pr oblem 6: Must tags be written in capital (upper case) letters?

Problem 7: When you typed in the above HTML document, some of the tags were indented (such as and ). Do you have to indent tags?

Problem 8: Based on your knowledge of the basic tags, write down exactly what you think will be printed by your browser for the following HTML document. The answer is given in the answer section. Let's assume that the , and tags have already been typed in.

<BODY> I am learning a lot about

designing my own web pages. </BODY></HTML>

THIS IS H2.

THIS IS NORMAL SIZE.

THIS IS H3.

THIS IS NORMAL SIZE.

THIS IS H4.

THIS IS NORMAL SIZE.

THIS IS H5.

THIS IS NORMAL SIZE.

THIS IS H6.

THIS IS NORMAL SIZE.

Note the following points: gives the largest size heading while gives the smallest size heading. In most browsers, the HEADER tags print the headings in boldface. A Level 1 heading (H1), because it is the largest heading, is considered to be the most prominent or most important heading. The Level 2 heading (H2) is the second most important heading. That is, it is more prominent than a Level 3 heading (H3) but less prominent than a Level 1 heading.

Good HTML form dictates that HEADER tags should be used in hierarchical order. Don't jump all over the place with your heading levels. For example, if you use a Level 2 heading for a title or heading, then the next size to use for a sub-title would be a level 3 heading.

If you look at the lines you typed in between the and tags, you did not type in any
or

commands. For example, we did not type in a
tag between "THIS IS H1" and "THIS IS NORMAL". Yet they were printed by the browser on separate lines. They should have been printed on the same line. Also, there is no
tag at the end of any line and so everything should have been printed by the browser on one long line. Well, the reason for all this is that HEADER tags (such as

) are very fussy. They don't want anything else on the same line with them. That is why "THIS IS NORMAL SIZE" was printed on a separate line. Also, the HEADER tags are not very sociable. They like to be separated from the rest of the crowd and so a HEADER tag will automatically place a blank or empty line above and below the heading. That is why you also see a blank line above and below each heading tag. For this reason, you do not need
and

tags with HEADER tags. Of course, if you want additional blank lines before or after a HEADER tag, you will then need to use
or

tags.

Final remarks on the HEADER tags:

  • After all that has been said here about the header tags, keep in mind that they are logical tags. This means that you cannot assume, for example, that H1 means "very

large bold text" in every browser. It will in most browsers - but you can't assume true in all browsers. It can be anything the browser chooses it to be - which could be defined by the viewer.
  • Some search engines give words appearing in headers more importance in their index. The headers are often used by these search engines to build an "outline" of the document which appears in the search results.

CENTERING TEXT The center command is: ALIGN="CENTER" (no spaces around the equal sign) and must be used in conjunction with a HEADER tag or the PARAGRAPH tag as in:

a heading goes here or

a paragraph or block of text goes here

Here are some points to remember concerning these two centering commands.

  • In the first example, a "heading" is centered (as indicated by the H2), and remember that because we are using a Header tag, a blank line will automatically be inserted before and after the heading. For this section, my heading "CENTERING TEXT" was centered using the H3 Header tag.
  • The second example is used to center whole portions of text - which could be several lines of text.

In other words, we are centering a "paragraph" or "block of text" with each line centered on the screen just as these lines are centered (hopefully). To end centering a block of text, we use the

tag which is the closing paragraph tag. This

tag is a new tag for us and one that you may not end up using all that often. But it does have its uses and this is one of them. Choose DOCUMENT SOURCE from the VIEW menu if you want to see how I centered these lines.

  • In ALIGN="CENTER", the ALIGN part is called an attribute. In the first example, ALIGN is the attribute for the Header tag. In the second example, ALIGN is the attribute for the Paragraph tag. An attribute provides extra information about the tag and the text it encloses. An attribute can have a value. In our two examples, the ALIGN attribute has the value "CENTER". In the first example, the browser is told to place (align) the heading in the "center" of the line. If a viewer should make the browser screen smaller, the heading will still remain centered in whatever the new screen size is. In the next example, a heading will be centered. When you do the example, be sure to try also ALIGN="RIGHT" and ALIGN="LEFT" (which is the default value if the ALIGN attribute is not used).

Now load the document into your browser and your web page should look like the following:

OUTDOOR LIVING IN ONTARIO

POINTS OF INTEREST

Northern Ontario:

Five Mile Lake Provincial Park

1.5 square miles. Camping, fishing ( walleye, northern pike, brook trout ), canoeing, self-

guided nature trails.

Recommended

Here are some questions for you to answer on the above example followed by a discussion on the emphasis tags.

Problem 3: Which tag appears to "bold" text?

Problem 4: Which tag tells the browser to write the text in italics?

Problem 5: How was the word "Recommended" printed?

Problem 6: Why is there no
tag at the end of the line "OUTDOOR LIVING IN

ONTARIO" or a

in front of the line "POINTS OF INTEREST" of the document you

typed in?

= EMPHASIZE TEXT

is used to emphasize text. It is a logical tag and so describes the meaning of the text to be displayed rather than how the text is to be displayed. In most browsers, the meaning is italics. However, if the browser doesn't support italics or the viewer changes the meaning, the browser will pick the best alternative way to display the text on the screen.

= STRONGLY EMPHASIZE TEXT is also a logical tag. It is used to strongly emphasize text. is distinct from . In most browsers, STRONG is identical to boldface. If a browser does not recognize boldface or if the viewer changes the meaning of STRONG, then the browser will pick the best alternative from the platform it is running on.

Using for Boldface or for Italics is accepted by all browsers as a way of strongly emphasizing text which in most cases is boldface. Instead of the and tags for strongly emphasizing text, you will sometimes see and for bolding text. While is a "Logical Style Command", is not. is a "Physical Style Command". A physical style command cannot be rendered differently.

Therefore if a browser does not accept the tag, then your text will simply not be bolded as the browser has no alternative way to display them on the screen. The same reasoning is also be applied for using the tag to print in italics instead of the tag. Now if for some reason you want to ensure only italics or boldface and nothing else, then use the italic font or the boldface font .

Here is your final problem to see how well you learned the information given in this lesson. Problem 7: Make up an HTML document in NOTEPAD that gives the following web page in the browser. In other words, when you are finished, your browser should show exactly the following:

TOSSED SALAD

Simple and attractive

1 large bunch of greens, preferably mixed 10 cherry tomatoes quartered

DRESSING 1/2 cup Mayonnaise 2 tbsp. Minced dill or sweet pickle 1 tsp. Prepared mustard 1/4 tsp. Onion powder 1 tsp. Granulated sugar 1 tbsp. Milk

Have greens ready in separate containers in refrigerator.

Dressing: Combine all ingredients together in a small bowl. Mix well. Spoon over greens. Toss to coat. Add tomato and toss together lightly. Serves 8

SYMBOLS

Here are some popular symbols and their ampersand commands that work in all browsers

Reading Assignment 1 Read about indenting and the various ways lists are created. That is using ordered, unordered, and definition lists and hence using notepad, write a script that will provide an output as shown below.

FINDING YOUR WAY IN THE WILDERNESS

  1. Seek expert advice about the area
    • Get the best maps. On the map select ✔ landmarks
      • mountains
      • lakes
    • Get a good compass and
      • check slope of land
      • check direction of flowing streams
    1. If there is snow on the ground, stay close to:
    • roads
    • trails and
    • waterways

If you are inexperienced do not travel alone do not travel at night If you do get lost Don't panic Don't wander in the dark Give distress signals at regular intervals such as:

  • three shouts
  • three small fires
  • three blasts of a whistle
  • three rifle shots

It may be wise to sit tight and wait for searchers