Introduction
Introduction
INTRODUCTION
Webpages are written in HTML - a simple scripting language.
documents.
When a browser opens an HTML file, the browser will look for HTML
codes in the text and use them to change the layout, insert images,
or create links to other pages.
INTRODUCTION
Since HTML documents are just text files they can be written in
even the simplest text editor.
There are excellent editors on the market that will take care of the
HTML parts. All you need to do is layout the page.
You can read the code of other people's pages, and "borrow" the
cool effects.
You can do the work yourself, when the editor simply refuses to
create the effects you want.
WHY LEARN HTML?
You can write your HTML by hand with almost any available text
editor, including notepad that comes as a standard program with
Windows.
All you need to do is type in the code, then save the document,
making sure to put an .html extension or an .htm extension to the
file (for instance "mypage.html").
TAGS
Basically, a computer sees an "A" as simply an "A" - whether it is
bold, italic, big or small.
To tell the browser that an "A" should be bold we need to put a
markup in front of the A.
Such a markup is called a Tag.
As you can see, the start tag <b> indicates that whatever follows
should be written in bold. The corresponding end tag </b> indicates
that the browser should stop writing text in bold.
PAGE STRUCTURE
All normal webpages consist of a head and a body.
The head is used for text and tags that do not show directly on
the page.
The body is used for text and tags that are shown directly on the
page.
telling the browser where the document starts and where it stops.
PAGE STRUCTURE
The most basic code - the code you will use for any page you make,
is shown below:
<html>
<head>
<!-- This section is for the title and technical info of the page. -->
</head>
<body>
<!-- This section is for all that you want to show on the page. -->
</body>
</html>
HEAD SECTION
The head section of the webpage includes all the stuff that does not
show directly on the resulting page.
The <title> and </title> tags encapsulate the title of your page. The
title is what shows in the top of your browser window when the page
is loaded.
Another thing you will often see in the head section is metatags.
Metatags are used for, among other things, to improve the rankings
in search engines.
HEAD SECTION
Quite often the head section contains javascript which is a
programming language for more complex HTML pages.
Finally, more and more pages contain codes for cascading style
sheets (CSS).
Since these aspects are way out of reach at this stage we will
proceed with explaining the body section.
BODY SECTION
The body of the document contains all that can be seen when the user loads the
page.
In the rest of this tutorial you can learn in detail about all the different aspects of
HTML, including: Text
Formatting
Resizing
Layout
Listing
Links
To local pages
To pages at other sites
To bookmarks
Images
Inserting images (GIF and jpg)
Adding a link to an image
Backgrounds
Colors
Images
Fixed Image
Tables
Frames
Forms
Metatags
Hexadecimal Colors
BASE FONT
To specify the overall font for your page add the <basefont> tag at the beginning
of the <body> section.
Example: The page as it looks in the browser.
Hello! This is my page.
All text looks the same
since I only specified a basefont.
The example below shows how to make the word here work as a
link to yahoo.
Click <a href="http://www.yahoo.com">here</a> to go to yahoo.
You simply:
Specify the target in the <a href=" ">.
text </font>
TEXT SIZE
The <small> and <big> tags are special in that they can
be repeated. If you want to increase the font size with a
factor two, then you could do it like this:
bla bla bla <big><big>whatever</big></big> bla bla bla
TEXT LAYOUT
<p>text</p> Adds a paragraph break after the text.
(2 linebreaks).
<p align="left">text</p> Left justify text in paragraph.
<p align="center">text</p> Center text in paragraph.
<p align="right">text</p> Right justify text in paragraph.
text<br> Adds a single linebreak where the tag is.
<nobr>text</nobr> Turns off automatic linebreaks
- even if text is wider than the window.
text<wbr> Allows the browser to insert a linebreak
at exactly this point
- even if the text is within <nobr> tags.
<center>text</center> Center text.
<div align="center">text</div> Center text.
To create a bulleted list you need to add a <ul> and a </ul> tag at the
beginning and the end of the list.
There are special settings that you can use to customize the lists on
your page.
BULLETED LISTS
<ul> Makes a bulleted list using the default bullet type:
<li>text</li> • text
<li>text</li> • text
<li>text</li> • Text
</ul>
<ol type="I" start="7"> An example of how type and start can be combined.
ROWS:
To add rows to your table use the <tr> and </tr> tags.
Example:
<table>
<tr></tr>
<tr></tr>
</table>
It doesn't make sense to write the above lines in itself, cause you can't write
content outside of table cells.
If you do write things outside of cells it will appear right above the table.
BASIC TABLES
COLUMNS:
You can divide rows into columns with <td> and </td> tags:
Example:
<table>
<tr> <td>This is row one, left side.</td>
<td>This is row one, right side.</td>
</tr>
<tr> <td>This is row two, left side.</td>
<td>This is row two, right side.</td>
</tr>
</table>
This is row one, left side. This is row one, right side.
This is row two, left side. This is row two, right side.
TABLE TAGS
Property Description
align= left align table
left center table
center right align table
right
background=filename image inserted behind the table
bgcolor=#rrggbb background color
border=n border thickness
bordercolor=#rrggbb border color
bordercolordark=#rrggbb border shadow
cellpadding=n distance between cell and content
cellspacing=n space between cells
nowrap protects agains linebreaks, even though the content might be
wider than the browser window.
TABLE TAGS
Property Description
frame=
void, removes all outer borders
above, shows border on top of table
below, shows border on bottom of table
lhs, shows border on left side of table
rhs, shows border on right side of table
hsides, shows border on both horizontal sides
vsides, shows border on both vertical sides
box shows border on all sides of table
valign=
top aligns content to top of cells
bottom aligns content to bottom of cells
width=
n,n minimum width of table in pixels
n,n% minimum width in percentage of window size
GIF & JPG
Computers store images in several different ways.
Some storage methods focus on compressing the size of the image as much as possible.
A major problem with using images on websites is that images take much longer to load than text.
To reduce download times as much as possible two of the best image compressing formats used on the
web are:
GIF JPG
This format is not good at compressing photographs Excellent for compressing photographs and complex images
In general, it is excellent for banners, buttons and clipart In general, it is not good for banners, buttons and clipart.
GIF & JPG
Here is the HTML code used to insert the image on this webpage:
<img src="http://www.check.com/rainbow.gif">
If the image is stored in the same folder as the HTML page, you can
leave out the domain reference (http://www.echoecho.com/) and
simply insert the image with this code:
<img src="rainbow.gif">
INSERTING IMAGE
You can change the size of an image using the width and height
attributes
<img src="http://www.check.com/rainbow.gif" width="120"
height="120">
You can add a border to the image using the border setting shown
in the example below:
Form fields are objects that allow the visitor to enter information - for
example text boxes, drop-down menus or radio buttons
A typical form example would be a search engine
There are dozens of free services on the web that will offer you free
CGI for almost any purpose you might have.
THE FORM TAG
When a form is submitted, all fields on the form are being sent.
The <form> tag tells the browser where the form starts and ends.
You can add all kinds of HTML tags between the <form> and
</form> tags.
Look at this example:
<html>
<head>
<title>My Page</title>
</head>
<body>
<!-- Here goes HTML -->
<form>
<!-- Here goes form fields and HTML -->
</form>
<!-- Here goes HTML -->
</body>
</html>
Note:
Unlike a table, forms are not visible on the page.
The address is the url of the cgi script the content should be sent to.
The post and get methods are simply two different methods for
submitting data to the script.
In the description of the script you are using it will be made clear
whether the scripts should be addressed using one method or the
other.
Example
Below is an example of a typical form tag, with both action and method
specified.
<html>
<head>
<title>My Page</title>
</head>
<body>
<!-- Here goes HTML -->
<form method="post" action="http://www.check.com/cgi-
bin/formmail.cgi">
<!-- Here goes form fields and HTML -->
</form>
<!-- Here goes HTML -->
</body>
</html>
All we need now, is to allow the visitor to enter some information
FORM FIELDS
These fields can be added to your forms:
Text field
Password field
Hidden field
Text area
Check box
Radio button
Drop-down menu
Submit button
Reset button
Image button
TEXT FIELD
Text fields are one line areas that allow the user to input text.
If you want several lines you should use a text area instead.
<form name="myform“
action="http://www.mydomain.com/myformhandler.cgi"
method="POST">
<div align="center">
<br><br>
<input type="text" size="25" value="Enter your name here!">
<br><br> </div> </form>
<input type="password" size="25">
<form name="myform"
action="http://www.mydomain.com/myformhandler.cgi"
method="POST">
<div align="center">
<select name="mydropdown">
<option value="Milk">Fresh Milk</option>
<option value="Cheese">Old Cheese</option>
<option value="Bread">Hot Bread</option>
</select>
</div>
</form>
FORM - BUTTONS
HTML EXPLANATION EXAMPLE
<input type="submit" value="Send me your name!">
<input type="reset" value="Reset!">
IMAGE BUTTON
HTML EXPLANATION EXAMPLE
A file that specifies how the screen is divided into frames is called a
frameset.
make the normal HTML documents that should be loaded into each
of these frames.
<html>
<head>
<title>My Frames Page</title>
</head>
<frameset cols="120,*">
<frame src="menupage.htm" name="menu">
<frameset rows="*,50">
<frame src="welcomepage.htm" name="main">
<frame src="bottombanner.htm" name="bottom">
</frameset>
</frameset>
</html>
Examples
On this page you can see examples of different
framesets. Top
Bottom
<frameset rows="16%,84%">
<frame src="top.htm" name="top">
<frame src="bottom.htm" name="bottom">
</frameset>
Examples
tl tr
bottom
<frameset rows="16%,84%">
<frameset cols="50%,50%">
<frame src="tl.htm" name="tl">
<frame src="tr.htm" name="tr">
</frameset>
<frame src="bottom.htm" name="bottom">
</frameset>
Examples
top
.
left right
<frameset rows="16%,84%">
<frame src="top.htm" name="top">
<frameset cols="50%,50%">
<frame src="left.htm" name="left">
<frame src="right.htm" name="right">
</frameset>
</frameset>
Examples
topleft topright
leftbottom rightbottom
botrbot
With plain HTML you define the colors and sizes of text and tables
throughout your pages. If you want to change a certain element you
will therefore have to work your way through the document and
change it.
With CSS you define the colors and sizes in "styles". Then as you
write your documents you refer to the styles. Therefore: if you
change a certain style it will change the look of your entire site.
Finally, CSS can be written so the user will only need to download it
once - in the external style sheet document. When surfing the rest of
your site the CSS will be cached on the users computer, and
therefore speed up the loading time.
CSS stands for Cascading Style Sheets. It is a way to divide the
content from the layout on web pages.
How it works:
A style is a definition of fonts, colors, etc.
Each style has a unique name: a selector.
The selectors and their styles are defined in one place.
Selectors are the names that you give to your different styles.
In the style definition you define how each selector should work
(font, color etc.).
HTML selectors
Used to define styles associated to HTML tags. (A way to redefine
the look of tags)
Class selectors
Used to define styles that can be used without redefining plain
HTML tags.
ID selectors
Used to define styles relating to objects with a unique ID (most often
layers)
TAG SELECTORS
The general syntax for an HTML selector is:
HTMLSelector {Property:Value;}
For example:
<HTML>
<HEAD>
<style type="text/css">
B {font-family:arial; font-size:14px; color:red}
</style>
</HEAD>
<BODY>
<b>This is a customized headline style bold</b>
</BODY>
</HTML>
HTML selectors are used when you want to redefine the general
look for an entire HTML tag.
CLASS SELECTORS
The general syntax for a Class selector is:
.ClassSelector {Property:Value;}
For example:
<HTML>
<HEAD>
<style type="text/css">
.headline {font-family:arial; font-size:14px; color:red}
</style>
</HEAD>
<BODY>
<b class="headline">This is a bold tag carrying the headline class</b>
<br>
<i class="headline">This is an italics tag carrying the headline class</i>
</BODY>
</HTML>
SPAN and DIV as carriers
Two tags are particularly useful in combination with class
selectors: <SPAN> and <DIV>
<HTML>
<HEAD>
<style type="text/css">
#layer1 {position:absolute; left:100;top:100; z-Index:0}
#layer2 {position:absolute; left:140;top:140; z-Index:1}
</style>
</HEAD>
<BODY>
<div ID="layer1">
<table border="1" bgcolor="#FFCC00"><tr><td>THIS IS LAYER
1<br>POSITIONED AT 100,100</td></tr></table>
</div>
<div ID="layer2">
<table border="1" bgcolor="#00CCFF"><tr><td>THIS IS LAYER
2<br>POSITIONED AT 140,140</td></tr></table>
</div>
</BODY>
</HTML>
GROUPED SELECTORS
.headlines{
font-family:arial; color:black; background:yellow; font-size:14pt;
}
.sublines {
font-family:arial; color:black; background:yellow; font-size:12pt;
}
.infotext {
font-family:arial; color:black; background:yellow; font-size:10pt;
}
For example, you can define a style for the <B> tag that is only
triggered if the text is not only bold but also written in italics.
<i><b>example</b></i>
<b>example</b>.
Simply adding a normal style to the <B> tag is done like this:
B {font-size:16px}
Adding a context dependent style, like the one described above is done
like this:
I B {font-size:16px;}
We simply separated the contextual <I> tag from the <B> tag with a
space.
USING GROUPED AND CONTEXT DEPENDENT
SELECTORS AT THE SAME TIME:
It is possible to use context dependent and grouped
selectors at the same time.
For example, like this:
I B, .headlines, B .sublines {font-size:16px;}
It is possible to create CSS styles that only work for the single
tag it is defined for.
Single tag CSS is used when the style is used in a single place
on the entire site.
If, however, that certain style is used on more than a single page,
you should use the third - and most powerful - technique
described: adding styles that are defined once for the entire site.
SINGLE TAGS
CSS can be defined for single tags by simply adding
style="styledefinition:styleattribute;" to the tags.
Look at this example:
It is <b style="font-size:16px;">NOT</b> me.
You should limit your use of single tag CSS.
If you define your styles for each and every tag they're used on, you will
lose much of the power associated with CSS.
For example, you will have to define the style over and over again
whenever it's used, rather than just defining it once and then referring to
that one definition whenever it's used.
.headlines {font-size:14pt;}
.sublines {font-size:12pt;}
.infotext {font-size: 10pt;}
</style>
</head>
<body>
<span class="headlines">Welcome</span><br>
<div class="sublines">
This is an example page using CSS.<br>
The example is really simple,<br>
and doesn't even look good,<br>
but it shows the technique.
</div>
<table border="2"><tr><td class="sublines">
As you can see:<br>
The styles even work on tables.
</td></tr></table>
<hr>
<div class="infotext">
Example from checkit.com.
</div>
<hr>
</body>
</html>
ENTIRE SITES
File: example.html
<html>
<head>
<title>MY CSS PAGE</title>
<link rel=stylesheet href="whatever.css" type="text/css">
</head>
<body>
<span class="headlines">Welcome</span><br>
<div class="sublines">
This is an example of a page using CSS.<br>
The example is really simple,<br>
and doesn't even look good,<br>
but it shows the technique.
</div>
<table border="2"><tr><td class="sublines">
As you can see:<br>
The styles even work on tables.
</td></tr></table>
<hr>
<div class="infotext">Example from CheckIT.Com.</div>
<hr>
</body>
</html>
The above example is the exact same as we used for CSS
defined for entire pages, with one important exception:
There is no style definition on the page. Instead we added a
reference to an external style sheet:
.headlines {font-size:14pt;}
.sublines {font-size:12pt;}
.infotext {font-size: 10pt;}
Now if you just add the line <link
rel=stylesheet href="whatever.css"
type="text/css"> to the <head> of all your
pages, then the one style definition will be in
effect for your entire site.