Html (1)
Webmaster
-
This is a basic starter kit for scripting webpages, like putting your toes into a swimming pool to test the temperature.
You can use your web pages from chapter 2, Your first website, to experiment as we go along.
UTF-8
Your external stylesheet does not have an html head or foot, so your first line must be:
@charset "utf-8";
which tells the user's server that your encoding is in the character set called "utf-8".
When you copy and paste from a document editor like MSWord into your simple text editior like Notepad, you carry across curved quotes, hyphens, question marks, and other punctuation not members of utf-8, so these must be replaced (using Menu >> Edit >> Replace with ...). Failing to do this, will cause the W3C validator to give an error like this :
Sorry ! I cannot validate this.
Reading further down the page will give you:
Sorry, I am unable to validate this document because on line 179 it contained one or more bytes that I cannot interpret as utf-8 ...
or similar. You will then ask: where is line xxx ? (I was told line 179 when there were only 140 lines in the file.)
When you see this vague message, guess the cause and seek those peculiar punctuation marks. For each punctuation, cut and paste into the upper textfield of the Edit-Replace dialogue box, add your Notepad version to replace it, and click [Replace all].
Save, and Revalidate to see if you have solved the problem.
Fonts
Headings are created by putting <h1> in front of the heading and </h1> after.
<h1> is called a tag, and is a formating instruction to the browser.
When I type "This is my <h1>heading</h1> for you to see." you see "This is my heading
for you to see.".
So this tag tells your browser to make the word "heading" bigger and bold, and to leave gaps above and below.
You can use h1, h2, h3, h4, h5, and h6 for slight differences. Try it.
To make a font bold, use <b></b>, as in <b>Remove the spaces.</b>
To make italics, use <i></i>, as in <i>Remove the spaces.</i>
I won't teach you how to underline, because underlined text is difficult to read, and should be avoided.
For a line-break to begin a new line, use <br /> which must have a space before the slash '/'.
For a paragraph with a gap before and after, then put <p> before, and </p> after.
For a paragraph without the gaps before and after, use <div>, </div>.
For a different color, try <div style="color:red">red text</div> as in red text.
Note that the tags <div></div> force the words "red text" onto their own line.
Since <div> forces a line-break, and </div> forces another line-break, if you want to change the style without forcing line-breaks, use <span></span>.
For one letter colored blue, try <span style="color:blue">B</span>lue as in Blue.
For one BIG letter colored green, try <span style="font-size: 24pt;color:green;">G</span>reen as in Green.
Note that style= is followed by quote marks. This is essential.
Note the use of ";" between attributes in style. This is essential.
Note the use of ":" between font and 24pt. Font is the attribute while 24pt is the value.
For truely bad taste, try <span style="font:24pt Arial;font-style:italic;color:green;">G</span>reen as in Green.
Firefox browser does not recognize style="font: italic;" and so it does not recognize anything after "italic" so that Firefox ignores 24pt and Arial in style="font: italic 24pt Arial;".
If I type style="font: 24pt italic Arial;", Firefox reads 24pt but ignores italic and Arial so I know there is a problem with the word italic.
This type of observation will help you debug your scripting.
Warning: Altho I can script style="font: 24pt/36pt italic Arial;", where 24pt is the font-size and 36pt is the line-height in which the text sits, when I did this as an example, Firefox ignored both 24pt font-size and 36pt line-height. It seemed that my scripting was faulty, BUT only because my computer did not offer 36pt line-height. My script did work for style="font:bold 24pt/48pt Arial".
Note that Firefox recognizes font-size:24pt; and font:24pt Arial; but not font:24pt.
Note that Firefox recognizes font-style:italic; but not font:italic.
The other popular browser, Internet Explorer or IE, seems to be more accommodating, but you should always write the best script in order that all browsers may display your pages attractively.
Bringing in images
We have already brought in an image into our file 4_f3.htm.
Look at the scripting we used:
<img src="1_parrot.jpg" />
The 3 letters following the dot, is called the file extension. In this case, jpg stands for jpeg which is a special format for images, along with .gif, .png. Microsoft uses .bmp for bitmap so convert to standard format.
The letters src stand for "source" of the information to be imported.
The letters img stand for "image". The image tag is <img />, which must have a space before the slash '/'.
Maintaining a website that grows and grows, becomes tiresome and time-consuming, so you need to be so organized that it takes only seconds to find the file you need. I number folders and files in the order in which they are called on the website.
All images are kept in folders called "images". All images are numbered in order of appearance. All images are named. Thus 1_parrot.jpg tells me this is a jpeg image of a parrot and it is the first image called on my website. I know to go to the book website, dive into the folder images, and it is the first in the list of images.
I recommend that you go into your www folder and create a folder, name it images, and click-and-drag the image 1_parrot.jpg into it.
Then go to file 4_f3.htm and change the text to:
<img src="images/11_parrot_lossy.jpg" />
Now click on your web page to bring it to the fore, and click on the keyboard key [f5] to refresh your screen. This makes your browser get all the files again, so that, if you have changed anything, the browser will read the latest version. Most important.
Does the image of the parrot display ? If not, check your script; check your spelling; check where the photo is.

Supposing your folders were arranged like this:
You simply want to stretch across to the folder called images, and dip your hand into it for the image. So that is how we link: "images/11_parrot_lossy.jpg".
Supposing your folders were arranged like this:
You would have to reach up out of one folder, 01, and down into one folder, images, like this:
"../images/11_parrot_lossy.jpg".
The "../" says "go up one folder".
Likewise "../../" says go up 2 folders.
Examine the next structure and write a call from the file 11_first.htm to the image 1_parrot.jpg.
Links to files
You have used links lots of times, and they are usually blue and underlined (tsk, tsk). Underlining is such a bad habit. If links are in luminescent-blue why underline as well ? You will have noticed that the links in my website are never underlined.
Let us link to our parrot by scripting:
<a href="images/11_parrot_lossy.jpg">Click for my parrot.</a>
Click for my parrot.
If you want to open a file or image in another window, you can target another window.
Try:
<a href="images/11_parrot_lossy.jpg" target="window2">Click for my parrot.</a>
Click for my parrot.
Linking thru images
You have clicked on a thumbnail images in Windows Explorer and on the web to open a bigger image.
Let us assume we have a thumbnail 11th_parrot.jpg and the large version 11_parrot_lossy.jpg in our folder images. Rename your parrot thumbnail to 11th_parrot.jpg.
The script for clicking on the thumbnail to bring the large image, is:
<a href="images/11_parrot_lossy.jpg"><img src="images/11th_parrot.jpg" alt="Rosella parrot thumbnail"/></a>
You need the larger photo, so click on the thumbnail to download the larger image, then right-click, drag to [Save image as], and save as 11_parrot_lossy.jpg in your folder images.
To return to this page, click the [Back] arrow above the top-left of this window.
By using the files you have created as templates, combined with these scripts, you now have the basic skills to handle your website.
It's confusing at first, but you will soon master it.
Happy scripting !