07 HTML
07 HTML
HTML
HTML Introduction
HTML Elements
HTML Formatting
HTML Entities
HTML Links
HTML Frames
HTML Tables
HTML Lists
HTML Forms
HTML Images
HTML Background
HTML Colors
HTML Colorvalues
HTML Colornames
HTML Layout
HTML Fonts
HTML Styles
HTML Head
HTML Meta
HTML URLs
HTML Scripts
HTML Attributes
HTML Events
HTML URL-encode
HTML Webserver
HTML Summary
HTML Introduction
What is an HTML file
HTML Elements
HTML documents are text files made up of HTML elements
HTML Formatting
How to format text using HTML
HTML Entities
Characters which have a special meaning in HTML
HTML Links
How to create and use links in an HTML document
HTML Frames
How to display more than one Web page in the same browser window
HTML Tables
Tables in an HTML document
HTML Lists
HTML supports ordered, unordered and definition lists
HTML Forms
HTML forms are used to select different kinds of user input
HTML Images
Displaying images in a document with HTML
HTML Background
Give a good background to make a Web site look great
HTML Colors
How to use colors in HTML
HTML Layout
What is a layout in HTML
HTML Fonts
The tag is used to add style, size, and color to the text on your site
HTML Head
The head element in HTML
HTML Meta
The meta element
HTML URLs
HTML Uniform Resource Locators
HTML Scripts
Add scripts to HTML pages to make them more dynamic and interactive
HTML Attributes
HTML 4.0 standard attributes
HTML Events
HTML 4.0 event attributes
HTML URL-encode
HTML URL-encoding reference
HTML Summary
Summary
Introduction to HTML
A markup language combines text and extra information about the text.
The extra information, for example about the text's structure or presentation, is expressed
using markup, which is intermingled with the primary text. The best-known markup language
in modern use is HTML (HyperText Markup Language), one of the foundations of the World
Wide Web. Historically, markup was (& is) used in the publishing industry in the
communication of printed work between authors, editors, and printers.
Creating an HTML document is very easy. To begin coding HTML, need only two things: a
simple-text editor! Notepad is the most basic of simple-text editors and you will probably code
a good amount of HTML with it.
HTML is platform independent; you will need to save your HTML files in standard text format,
sometimes known as ASCII. The easy way to do this is use a program like [Link] in
Windows, pico in Linux, and the like.
If you'd prefer to use a word processor like Word or WordPerfect to write HTML code, you can
do so, but need to save your files as "Text" or "Text Only. " You will see this option in a drop
down box in your "Save As..." screen.
If you use a word processor and forget to save it as Text format, you will see only
garbled data when you try to view the page with a web browser.
The most common mistake for designers is the urge to put the d:\ in links and images. When
you are on the web, there is no d:\ to the rest of the world. When you start out, keep all your
HTML files and images in one folder, and don't use d:\ at all.
Quick example:
<img> loads an image into a web page. If you have a file called [Link], use the code <img
src="[Link]"> to load it, not <img src="c:\My Documents\website\[Link]">
HyperText Markup Language: HTML is a plain text file with commands <markup tags> to tell
Web browsers how to display the file. Tim Berners-Lee created HTML while at CERN, (the
European Laboratory for Particle Physics) in Geneva.
There are slight differences between browsers, such as Netscape Navigator and Microsoft
Internet Explorer, in areas such as page margins. The only real answer is to use standard
HTML tags whenever possible, and view your pages in multiple browsers to see how they look.
You can do all your training on a non-Windows computer like a Mac. However, some of the
examples in our advanced classes require a newer version of Windows.
It's good to validate your HTML. Just because you can see the Web page ok on your browser
doesn't mean every browser will show it that way or even be able to access the Web page.
Browsers attempt to "work around" HTML errors, and the differences can be subtle or drastic.
That's why the folks at WC3 have worked up the specifications of what works for every
browser. Although some may display it a little different, at least you know they can access
your page. (The different browser programs have their own set of "whistles and bells" that just
won't do the same... especially Microsoft Internet Explorer and Netscape Navigator.)
» After I have edited an HTML file, I cannot view the result in my browser.
Why?
Make sure that you have saved the file with a proper name and extension like
"c:\[Link]". Also make sure that you use the same name when you open the file in your
browser.
HTML Elements
Many HTML elements include attributes in their start tags. Attributes are defining desired
behavior or indicating additional element properties. The end tag is optional for many
elements. There are a few elements that are not part of any official DTDs, yet are supported
by some browsers and used by some web pages. Such elements may be ignored or displayed
improperly on browsers not supporting them.
HTML Tags
Informally, HTML elements are sometimes referred to as "tags", though many prefer the term
tag strictly in reference to the semantic structures delimiting the start and end of an element.
• HTML tags are surrounded by the two characters < and >
• The first tag in a pair is the start tag(<i>), the second tag is the end tag(</i>)
• The element content is the text between the start and end tags
• HTML tags are not case sensitive, <b> means the same as <B>
<HTML>
This tag is used to indicate that this is an HTML document. Most HTML documents should start
and end with this tag.
<head>
This tag is used to indicate the header section of the HTML document, which typically includes
the <title> and <meta> tags, and is not displayed in the main window of the browser.
<title>
This tag indicates the title of this HTML page. The title is what is displayed on the upper left
corner of the browser when you view a web page. The title tag is important when it comes to
search engine ranking. Many of the search engines pay special attention to the text in the
<title> tag. This is because (logically) that words in the <title> tag indicate what the page
content is.
<meta>
The <meta> tag information is not directly displayed when the page is rendered on the
browser. Rather, this is used for the author of the HTML page to record information related to
this page. Two common attributes are name and content. The <meta> tag used to hold
great importance in search engine optimization, with authors carefully drafting what's inside
the tag to gain better search engine ranking, but recently its importance has been decreasing
steadily.
<body>
The <body> tag includes the HTML body of the document. Everything inside the <body> tag
(other than those within the <script> tag) is displayed on the browser inside the main browser
window.
The <body> tag may contain several attributes. The most commonly used ones are listed
below:
• bgcolor: This is the background color of the entire HTML document, and may be
specified either by the color name directly or by the six-digit hex code.
• alink: The color of the links.
• vlink: The color of the visited links.
• topmargin: The margin from the top of the browser window.
• leftmargin: The margin from the left of the browser window.
Headings
Headings are defined with the <h1> to <h6> tags. <h1> defines the largest heading. <h6>
defines the smallest heading.
<h1>This is a heading</h1>
<h2>This is a heading</h2>
<h3>This is a heading</h3>
<h4>This is a heading</h4>
<h5>This is a heading</h5>
<h6>This is a heading</h6>
HTML automatically adds an extra blank line before and after a heading.
Line Breaks
The <br> tag is used when you want to end a line, but don't want to start a new paragraph.
The <br> tag forces a line break wherever you place it.
Comments in HTML
The comment tag is used to insert a comment in the HTML source code. A comment will be
ignored by the browser. You can use comments to explain your code, which can help you
when you edit the source code at a later date.
Note that you need an exclamation point after the opening bracket, but not before the closing
bracket.
HTML Formatting
<font>
The <font> tag is used to change the format of the text on the web page. The most important
attributes are as follows:
face: The type of font. Common ones include "Time New Roman", "Verdana", and "Helvetica."
size: This indicates the size of the text. This can be absolute (0 .. 6), or relative ("+1", ... or
"-1",...)
color: This attribute indicates the color of the text. Either the color name or the six-character
color code may be used to specify color.
<font size=2 face="Helvetica" color=red>This illustrates the attributes of the font tag.</font>
<b>
The <b> tag will bold the text inside the tag.
<i>
The <i> tag will italicize the text inside the tag.
<u>
The <u> tag will underline the text inside the tag.
<center>
The <center> tag causes all the text within the tag to be centered.
<p>
The <p> tag indicates a new paragraph. It is the same as <br><br>. This tag is most often
used by itself, without a corresponding closing tag.
<big>
<em>
<small>
<strong>
<sub>
<sup>
<ins>
<del>
<code>
<kbd>
<samp>
<tt>
<var>
Defines a variable
<pre>
• An entity is a fancy term for a symbol. Several symbols such as copyright, trademark,
or foreign cash symbols exist outside of the ones you see on your keyboard. In order
to display them. In order to display these characters, you need to know 4 parts.
• In HTML we use less than and greater than characters to create tags, so to use them
on your web site you will need entities.
HTML Links
• The link starts at the "source" anchor and points to the "destination" anchor,
which may be any Web resource (e.g., an image, a video clip, a sound bite, a
program, an HTML document, an element within an HTML document, etc.).
The <a> tag is used to create an anchor to link from, the href attribute is used to address the
document to link to, and the words between the open and close of the anchor tag will be
displayed as a hyperlink.
To create a named anchor the name attribute is used. The name of the anchor can be any text
you care to use. The line below defines a named anchor:
You should notice that a named anchor is not displayed in a special way.
To link directly to the a section, add a # sign and the name of the anchor to the end of a URL,
like this:
<a href="[Link] Jump to the Main Section</a>
A hyperlink to the Main Section from within the file "[Link]" will look like this:
<a href="#main">Jump to the Main Section</a>
HTML Frames
• With frames, you can display more than one Web page in the same browser
window.
Using frames, You can display more than one HTML document in the same browser window.
Each HTML document is called a frame, and each frame is independent of the others.
The disadvantages of using frames are:
• The <frameset> tag defines how to divide the window into frames
• Each frameset defines a set of rows or columns
• The values of the rows/columns indicate the amount of screen area each row/column
will occupy
• The <frame> tag defines what HTML document to put into each frame
In the below example we have a frameset with two columns. The first column is set to 25% of
the width of the browser window. The second column is set to 75% of the width of the browser
window. The HTML document "frame_x.htm" is put into the first column, and the HTML
document "frame_y.htm" is put into the second column:
<frameset cols="25%,75%">
<frame src="frame_x.htm">
<frame src="frame_y.htm">
</frameset>
HTML Tables
The HTML table model allows authors to arrange data -- text, preformatted text,
images, links, forms, form fields, other tables, etc. -- into rows and columns of cells.
Tables
<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2p</td>
</tr>
</table>
Headings in a Table
Headings in a table are defined with the <th> tag.
<table border="1">
<tr>
<th>Heading</th>
<th>Another Heading</th>
</tr>
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2p</td>
</tr>
</table>
<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
</table>
<table border="1">
<tr>
<td>column1</td>
<td>column2</td>
<td>column3</td>
</tr>
<tr>
<td rowspan="2">row 1, cell 1</td>
<td>row 1, cell 2</td>
<td>row 1, cell 3</td>
</tr>
<tr>
<td>row 2, cell 2</td>
<td>row 2, cell 3</td>
</tr>
<tr>
<td colspan="3">row 3, cell 1</td>
</tr>
</table>
O/P:
column1
column2
column3
row 1, cell 1
row 1, cell 2
row 1, cell 3
row 2, cell 2
row 2, cell 3
row 3, cell 1
row 2, cell 1
row 2, cell 2
HTML Lists
HTML offers authors several mechanisms for specifying lists of information
Unordered Lists
An unordered list is a list of items. With bullets the list items are marked (typically small black
circles).
An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.
<ul>
<li>list item1</li>
<li>list item2</li>
</ul>
O/P:
list item1
list item2
<ul type="disc">
<li>list item1</li>
<li>list item2</li>
</ul>
O/P:
• list item1
• list item2
<ul type="circle">
<li>list item1</li>
<li>list item2</li>
</ul>
O/P:
o list item1
o list item2
Ordered Lists
An ordered list is also a list of items. The list items are marked with numbers.
An unordered list starts with the <ol> tag. Each list item starts with the <li> tag.
<ol>
<li>list item1</li>
<li>list item2</li>
</ol>
O/P:
1. list item1
2. list item2
Using the start attribute start your ordered list on any number besides 1.
<ol start="4" >
<li>list item1</li>
<li>list item2</li>
</ol>
O/P:
4. list item1
5. list item2
There are 4 other types of ordered lists. You can replace generic numbers with Roman
numberas or letters, both capital and lower-case. Use the type attribute to change the
numbering.
<ol type="a">
<li>list item1</li>
<li>list item2</li>
</ol>
O/P:
a. list item1
b. list item2
<ol type="A">
<li>list item1</li>
<li>list item2</li>
</ol>
O/P:
A. list item1
B. list item2
<ol type="i">
<li>list item1</li>
<li>list item2</li>
</ol>
O/P:
i. list item1
ii. list item2
<ol type="I">
<li>list item1</li>
<li>list item2</li>
</ol>
O/P:
I. list item1
II. list item2
Definition Lists
A definition list is not a list of items. This is a list of terms and explanation of the terms.
O/P:
Definition list term1
Definition list definition1
Definition list term2
Definition list definition1
Forms
An HTML form is a section of a document containing normal content, markup, special elements
called controls (checkboxes, radio buttons, menus, etc.), and labels on those controls. Users
generally "complete" a form by modifying its controls (entering text, selecting menu items,
etc.), before submitting the form to an agent for processing (e.g., to a Web server, to a mail
server, etc.)
This attribute specifies a form processing agent. User agent behavior for a value other than an
HTTP URI is undefined.
When the user clicks on the "Submit" button, the content of the form is sent to another file.
The form's action attribute defines the name of the file to send the content to. Usually the file
defined in the action attribute does something with the received input.
Method attribute specifies which HTTP method will be used to submit the form data set.
Possible (case-insensitive) values are "get" (the default) and "post".
One can specify two different submission methods for a form in HTML. The difference between
METHOD="GET" (the default) and METHOD="POST" is primarily defined in terms of form data
encoding. The official recommendations say that "GET" should be used if and only if the form
processing is idempotent, which typically means a pure query form. Generally it is advisable to
do so. There are, however, problems related to long URLs and non-ASCII character repertoires
which can make it necessary to use "POST" even for idempotent processing.
get: With the HTTP "get" method, the form data set is appended to the URI specified by the
action attribute (with a question-mark ("?") as separator) and this new URI is sent to the
processing agent.
post: With the HTTP "post" method, the form data set is included in the body of the form and
sent to the processing agent.
enctype
This attribute specifies the content type used to submit the form to the server (when the value
of method is "post"). The default value for this attribute is "application/x-www-form-url
encoded". The value "multipart/form-data" should be used in combination with the INPUT
element, type="file".
Input
The most used form tag is the <input> tag. The type of input is specified with the type
attribute.
Text Fields
Text fields are used when you want the user to type something (letters, numbers, etc.) in a
form. In most browsers, by default the width of the text field is 20 characters.
<form>
First name:
<input type="text" name="firstname">
<br>
Last name:
<input type="text" name="lastname">
</form>
O/P:
First name:
Last name:
Password Fields
Password fields are a special type of <input /> tag. All that we need to do is change the type
attribute from text to password.
<form>
<input type="password">
<input type="password" size="5" maxlength="5">
<input type="password" size="15" maxlength="15" >
<input type="password" size="25" maxlength="25" >
</form>
O/P:
Radio Buttons
Radio Buttons are used when you want the user to select one of a limited number of choices.
<form>
<input type="radio" name="sex" value="male"> Male
<br>
<input type="radio" name="sex" value="female"> Female
</form>
O/P:
Male
Female
Checkboxes
Checkboxes are used when you want the user to select one or more options of a limited
number of choices.
<form>
<input type="checkbox" name="bike"> Bike
<br>
<input type="checkbox" name="car"> Car
</form>
O/P:
Bike
Car
Textarea
A text-area is a multi-line text input control. A user can write text in the text-area. In a text-
area you can write an unlimited number of characters.
Rows and columns need to be specified as attributes to the <textarea> tag. Rows are
roughly 12pixels high, the same as in word programs and the value of the columns reflects
how many characters wide the text area will be.
wrap=
"off"
"virtual"
"physical"
Virtual means that the viewer will see the words wrapping as they type their comments, but
when the page is submitted to you, the web host, the document sent will not have wrapping
words.
Physical means that the text will appear both to you, the web host, and the viewer including
any page breaks and additional spaces that may be inputed. The words come as they are.
Off turns off word wrapping within the text area. One ongoing line.
<form>
<textarea rows="5" cols="20" wrap="physical" name="comments">
Enter Comments Here
</textarea>
</form>
O/P:
With the <select> and <option> tags drop down menus are created.
<select> is the list itself and each <option> is an available choice for the user.
<form>
<select name="ourSites">
<option>[Link]</option>
<option>[Link]</option>
<option>[Link]</option>
<option>[Link]</option>
<option>[Link]</option>
<option>[Link]</option>
<option>[Link]</option>
</select>
</form>
O/P:
Selection List
Selection list is basically just another type of way to get input from the user.
The size attribute selects how many options will be shown at once before needing to scroll,
and the selected option tells the browser which choice to select by default.
<form>
<select multiple name="ourSites" size="4">
<option>[Link]</option>
<option>[Link]</option>
<option>[Link]</option>
<option>[Link]</option>
<option>[Link]</option>
<option>[Link]</option>
<option>[Link]</option>
</select>
</form>
O/P:
vyomw [Link]
testsw [Link]
[Link]
[Link]
Submit Button
The submit button will send all input form data to the destination declared in the form action
command. If you do not give your submit button a value the button will display Submit Query
by default. Placing any other text in the value will display within the button.
<form>
First name:
<input type="text" name="firstname">
<br>
Last name:
<input type="text" name="lastname">
<br>
<input type="submit" value="Submit Here">
</form>
O/P:
First name:
Last name:
Submit Here
HTML Images
It announces to the browser that an image will go here on the page. Yes, the image will pop
up right where you write in the image tag.
SRC
SRC stands for "source." This again is an attribute, a command inside a command. The value
of the src attribute is the URL of the image you want to display on your page. It's telling the
browser where to go to find the image. Again, it's best for you to place the images you want
to use in the same directory as the page. This way you can call for the image by name alone.
If you start to place your images all over the place, you'll have to start adding directories and
sub-directories to the SRC attribute. And at this point, that is way too confusing. Just place
the image in the same place as the HTML document that will call for it and then call for the
image by name alone. You can get fancy later. Right now, let's just get it to work.
[Link]
[Link] is the name of the image. Notice it's following the same type of format as your
HTML documents. There is a name (image) then a dot and then there is a suffix (gif).
ALT
ALT stands for "alternate text". This tells the browser that if it can't find the image, then just
display this text. It also tells anyone who can't view your image what the image is about. For
example a disabled user using a screen reader, or dare I mention it, Search Engines.
"some text"
"some text" is where you put the text describing your image.
Image Formats
There are four basic formats you will find on the World Wide Web
.gif
gif This is pronounced "jif" or "gif" (hard "G") depending on whom you speak to. I have
always said "jif", like the peanut butter. This is an acronym for Graphics Interchange Format.
The format was invented by CompuServe and it's very popular. The reason is that it's a simple
format. It's a series of colored picture elements, or dots, known as pixels, that line up to make
a picture. Your television's picture is created much the same way. Browsers can handle this
format quite easily.
.png
.png .png Pronounced as 'ping', this stands for Portable Network Graphic. This is ultimately
the replacement for .gif, with partial transparency options, but browser support is sometimes
disappointing, so try experimenting but don't expect miracles in older browsers! Even some of
the newer ones don't like partial transparency.
.jpeg or .jpg
.jpeg or .jpg (pronounced "j-peg") There are two names to denote this format because of the
PC and MAC formats allowing 3 and 4 letters after the dot. JPEG is an acronym for Joint
Photographic Experts Group, the organization that invented the format. The format is unique
in that it uses compression after it's been created. That's fancy computer talk that means that
when the computer is not using a .jpeg image it folds it up and puts it away. For example, if
the picture is 10K bytes when displayed, it may be only 4K bytes when stored. Nice trick, huh?
It saves on hard drive space, but also tends to require a bit of memory on your part to unfold
the image. Someone always writes to me to tell me that .gif images also use compression.
Yes, they do, but only when they are first created into that format. After that, no compression.
JPEG, on the other hand, uses compression throughout its life to fold up smaller than it really
is.
.bmp
.bmp (pronounced "bimp") This is a "bitmap." You will probably never place a bitmap as an
image, although now Internet Explorer browsers allow it. A bitmap is an image that a
computer produces and places for you. A counter is an example.
Even though Internet Explorer will allow you to place an image as a BMP, I wouldn't. No other
browsers will be able to display it. Go with .gif or JPEG.
HTML Backgrounds
Backgrounds
The <body> tag has two attributes where you can specify backgrounds. The background can
be a color or an image.
Bgcolor
This attribute specifies a background-color for an HTML page. The value of this attribute can
be a hexadecimal number, an RGB value, or a color name:
<body bgcolor="#000000">
<body bgcolor="rgb(0,0,0)">
<body bgcolor="black">
The URL can be relative (as in the first line above) or absolute (as in the second line above).
HTML Colors
Color Values
Colors are defined using a hexadecimal notation for the combination of Red, Green, and Blue
color values (RGB). The lowest value that can be given to one light source is 0 (hex #00). The
highest value is 255 (hex #FF).
RGB Values
RGB stands for Red, Green, Blue. Each can have a value from 0 (none of that color) to 255
(fully that color). The format for RGB is - rgb(RED, GREEN, BLUE), just like the name implies.
We do not recommend that you use RGB for safe web design because non-IE browsers do not
support HTML RGB. However, if you plan on learning CSS then you should glance over this
topic.
bgcolor="rgb(255,255,255)" White
bgcolor="rgb(255,0,0)" Red
bgcolor="rgb(0,255,0)" Green
bgcolor="rgb(0,0,255)" Blue
bgcolor="rgb(0,0,0)" Black
Hexadecimal
Hexadecimals are far more reliable and widely compatible among web browsers and are the
standard for colors on the internet.
A hexadecimal is a 6 digit representation of a color. The first two digits(RR) represent a red
value, the next two are a green value(GG), and the last are the blue value(BB).
Zero, "0", is the smallest representations of a color. It's almost the total absence of color. F is
15 times the intensity of the color of 0. Combinations of these digits create different shades of
a particular color. Double Zero, "00," is equal to zero hue. FF is equal to a pure color.
This color representation is done three times, once for red, once for green, and once for blue,
in that order. Put the three, two-digit, codes together and you get a 6-digit hex code. The hex
code is just a representation of the red, green, and blue intensity, in that order. The computer
creates the three intensities, mashes them together, and you get a single shade of color.
Color Names
Color Values
HTML colors are defined using a hexadecimal notation for the combination of Red, Green, and
Blue color values (RGB). The lowest value that can be given to one of the light sources is 0
(hex #00). The highest value is 255 (hex #FF).
<h2> . . . </h2>
<h3> . . . </h3>
<h4> . . . </h4>
<h5> . . . </h5>
<h6>Smallest Heading</h6>
A named anchor:
<a name="tips">Useful Tips Section</a>
<a href="#tips">Jump to the Useful Tips Section</a>
Ordered list<ol>
<li>First item</li>
<li>Next item</li>
</ol>
Tables
<table border="1">
<tr>
<th>someheader</th>
<th>someheader</th>
</tr>
<tr>
<td>sometext</td>
<td>sometext</td>
</tr>
</table>
Frames
<frameset cols="25%,75%">
<frame src="[Link]">
<frame src="[Link]">
</frameset>
Forms
<select>
<option>Apples
<option selected>Bananas
<option>Cherries
</select>
</form>
Other Elements
<blockquote>
Text quoted from some source.
</blockquote>
<address>
Address 1<br>
Address 2<br>
City<br>
</address>
HTML Layout
One very common practice with HTML, is to use HTML tables to format the layout of an HTML
page. An HTML <table> is used to divide a part of this Web page into two columns. The trick
is to use a table without borders, and maybe a little extra cell-padding. No matter how much
text you add to the page, it will stay inside its column borders.
O/P:
Content1 Content1 Content1 Content1 Content1 Content1 Content1 Content1 Content1
Content1 Content1
Content2 Content2 Content2 Content2 Content2 Content2 Content2 Content2 Content2
Content2 Content2
O/P:
Content1 Content1 Content1 Content1 Content1 Content1 Content1 Content1 Content1
Content1 Content1
Content2 Content2 Content2 Content2 Content2 Content2 Content2 Content2 Content2
Content2 Content2
HTML Fonts
The <font> tag is used to add style, size, and color to the text on your site. Use the
size, color, and face attributes to customize your fonts. Use a <basefont> tag to set
all of your text to the same size, face, and color.
Even if a lot of people are using it, you should try to avoid it, and use styles instead.
O/P:
This is a paragraph.
Font Attributes
The original HTML was never designed to contain tags for formatting a document. HTML tags
were intended to define the content of the document like:
<p>This is a paragraph</p>
<h1>This is a heading</h1>
When color attributes and tags like <font> were added to the HTML 3.2 specification, it
started a nightmare for web developers. Development of large web sites where fonts and color
information had to be added to every single Web page, became a long, expensive and difficult
process.
All formatting can be removed from the HTML document and stored in a separate style
sheet in HTML 4.0 .
Because it separates the presentation from the document structure in HTML 4.0, we have what
we always needed: Total control of presentation layout without messing up the document
content.
Do not use presentation attributes inside your HTML tags if you can avoid it. Start using
styles!
XHTML is the "new" HTML. Start writing valid HTML 4.01. Also start writing your tags in lower
case. Always close your tag elements. Never end a paragraph without </p>.
The official HTML 4.01 recommends the use of lower case tags.
HTML Styles
All formatting can be moved out of the HTML document and into a separate
style sheet with HTML 4.0.
Inline Styles
When a unique style is to be applied to a single occurrence of an element an inline style
should be used.
To use inline styles, use the style attribute in the relevant tag. The style attribute can contain
any CSS property. The example shows how to change the color and the left margin of a
paragraph:
<p style="color: red; margin-left: 20px">
This is a paragraph
</p>
Style Tags
Tag Description
<style> Defines a style definition
<link> Defines a resource reference
<div> Defines a section in a document
<span> Defines a section in a document
<font> Deprecated. Use styles instead
<basefont> Deprecated. Use styles instead
<center> Deprecated. Use styles instead
HTML Head
Within <HTML>, the document has two sections to it: <HEAD> and <BODY
...>.
The title information inside a head element is not displayed in the browser
window.
The elements inside the head element should not be displayed by a browser.
According to the HTML standard, only a few tags are legal inside the head section.
These are: <base>, <link>, <meta>, <title>, <style>, and <script>.
<head>
<title>My page title</title>
</head>
Head Tags
Tag Description
<head> Defines information about the document
<title> Defines the document title
<base> Defines a base URL for all the links on a page
<link> Defines a resource reference
<meta> Defines meta information
Tag Description
<!DOCTYPE> Defines the document type. This tag goes before the <HTML> start
tag.
HTML Meta
The purpose of the meta element is to provide meta-information about the
document.
Meta tags are used to supply information for search engines that will not be
seen by the web surfer unless they were to view your web site's HTML.
In the past, meta tags were a primary way for the site to be recognized by
web spiders, but the internet community abused the meta tags to artificially
increase their ranking in the search engine databases.
The intention of the name and content attributes is to describe the content of a page.
However, some search engines have stopped using them entirely, since too many webmasters
have used meta tags for spamming, like repeating keywords to give pages a higher ranking.
Then you just have to accept that this is something unique to the site or to the author of the
site, and that it has probably no relevance to you.
HTML Links
In an HTML document when you click on a link, an underlying <a> tag points to a place (an
address) on the Web with an href attribute value like this: <a href="[Link]">Last
Page</a>.
Internal - href="#anchorname"
Local - href="../pics/[Link]"
Global - href="[Link]
The scheme is defining the type of Internet service. The most common type is http.
The domain is defining the Internet domain name like [Link].
The host is defining the domain host. If omitted, the default host for http is www.
The :port is defining the port number at the host. The port number is normally omitted. The
default port number for http is 80.
The path is defining a path (a sub directory) at the server. If the path is omitted, the
resource (the document) must be located at the root directory of the Web site.
The filename is defining the name of a document. The default filename might be [Link],
or [Link] or something else depending on the settings of the Web server.
URL Schemes
Some examples of the most common schemes can be found below:
Schemes Access
file a file on your local PC
ftp a file on an FTP server
http a file on a World Wide Web Server
gopher a file on a Gopher server
news a Usenet newsgroup
telnet a Telnet connection
WAIS a file on a WAIS server
Accessing a Newsgroup
The following HTML code:
<a href="news:[Link]">HTML Newsgroup</a>
creates a link to a newsgroup like this HTML Newsgroup. HTML Newsgroup
HTML Scripts
HTML Scripts
There are two popular scripts that are commonly used in HTML to make web pages come
alive. HTML javascript and HTML vbscript With HTML scripts you can create dynamic web
pages, make image rollovers for really cool menu effects, or even validate your HTML form's
data before you let the user submit.
<HTML>
<head>
</head>
<body>
<script type="text/javascript">
[Link]("Hello World!")
</script>
</body>
</HTML>
A browser that does not recognize the <script> tag at all, will display the <script> tag's
content as text on the page. To prevent the browser from doing this, you should hide the
script in comment tags. An old browser (that does not recognize the <script> tag) will ignore
the comment and it will not write the tag's content on the page, while a new browser will
understand that the script should be executed, even if it is surrounded by comment tags.
Example
JavaScript:
<script type="text/javascript">
<!--
[Link]("Hello World!")
//-->
</script>
VBScript:
<script type="text/vbscript">
<!--
[Link]("Hello World!")
'-->
</script>
In addition to hiding the script inside a comment, you can also add a <noscript> tag.
The <noscript> tag is used to define an alternate text if a script is NOT executed. This tag is
used for browsers that recognize the <script> tag, but do not support the script inside, so
these browsers will display the text inside the <noscript> tag instead. However, if a browser
supports the script inside the <script> tag it will ignore the <noscript> tag.
JavaScript:
<script type="text/javascript">
<!--
[Link]("Hello World!")
//-->
</script>
<noscript>Your browser does not support JavaScript!</noscript>
VBScript:
<script type="text/vbscript">
<!--
[Link]("Hello World!")
'-->
</script>
<noscript>Your browser does not support VBScript!</noscript>
Script Tags
Tag Description
<script> Defines a script
<noscript> Defines an alternate text if the script is not executed
<object> Defines an embedded object
<param> Defines run-time settings (parameters) for an object
<applet> Deprecated. Use <object> instead
At some point you may want to give your body element a background color
or perhaps change the width or of a table. All of these things and more can
be achieved using Attributes.
The attributes listed here are the core and language attributes that are standard for all tags
(with a few exceptions):
Core Attributes
Not valid in base, HTML, head, meta, param, script, style, and title elements.
Language Attributes
Not valid in base, br, hr, frame, frameset, iframe, param, and script elements.
Keyboard Attributes
Below is a list of attributes that can be inserted into HTML tags to define
event actions.
Window Events
Only valid in body and frameset elements.
Keyboard Events
Not valid in base, bdo, br, frame, frameset, head, HTML, iframe, meta, param, script, style,
and title elements.
Mouse Events
Not valid in base, bdo, br, frame, frameset, head, HTML, iframe, meta, param, script, style,
title elements.
´ %b4 ä %e4
µ %b5 å %e5
¶ %b6 æ %e6
· %b7 ç %e7
¸ %b8 è %e8
¹ %b9 é %e9
º %ba ê %ea
» %bb ë %eb
¼ %bc ì %ec
½ %bd í %ed
¾ %be î %ee
¿ %bf ï %ef
Web Server
• You must publish your pages, if you want other people to view them.
• You have to copy your files to a web server, to publish your work.
• Your own PC can act as a web server if it is connected to a network.
• You can use the PWS (Personal Web Server), if you are running Windows 98.
• PWS is hiding in the PWS folder in your Windows CD.
PWS turns any Windows computer into a Web server. PWS is easy to install and ideal for
developing and testing Web applications. PWS has been optimized for workstation use, but has
all the requirements of a full Web server. It also runs Active Server Pages (ASP) just like its
larger brother IIS.
Note: Microsoft Windows XP Home Edition does not come with the option to turn your
computer into a PWS!
Windows 2000's built-in Web server IIS, makes it easy to build large applications for the Web.
Both PWS and IIS include ASP, a server-side scripting standard that can be used to create
dynamic and interactive Web applications. IIS is also available for Windows NT.
Note: Microsoft Windows XP Home Edition does not come with the option to turn your
computer into a PWS!
HTML Summary
HTML Summary
HTML is the universal markup language for the Web. HTML lets you format text, add graphics,
create links, input forms, frames and tables, etc., and save it all in a text file that any browser
can read and display.