Beruflich Dokumente
Kultur Dokumente
What is HTML?
To begin using HTML, you will need to have a few things. Here is the big list of
items you need to have to get started:
1. You will need to have a computer that is running. Most likely you have this
already, since you are reading this page.
2. You will need a text editor of your choice. If you have windows, Notepad
will do the trick. If you have a Mac, you can use BBEdit. To find
Notepad/BBEdit on your computer:
3. You will need a Web browser of your choice. If you possibly can, use the
latest version of Firefox, Netscape Navigator, or Microsoft Internet
Explorer.
4. You will need a place to save your work. You can use your hard drive, a
floppy disk, or your Web server. You don't have to work online, you can
write the HTML and use your Web browser offline on your own computer.
We will get to that shortly, in the next tutorial.
<html>
<head>
<title>Test Page</title>
</head>
<body>
Hi there, you have just written your first Web page! I am Mayura from
Sri
Lanka..
</body>
</html>
Once you have finished, go to the "File" menu and click on "Save As". This will
prompt you to create a name for your file. In the box, type in: test.htm
At the bottom of the prompt you should see a space that says "Save file as Type"
or "Save as Type". The default is .txt, so you will need to change it. Click on the
down arrow on the right side of the input box. You should be able to highlight All
Files(*.*) . Click on this to make the change. You should see something similar
to the picture below:
This is an example using Windows xp. The text was enlarged so you could see
the part we are interested in at this point. Now you may choose the drive and
If you do not get the option to save the file as the type All Files(*.*) , then
select the plain text file type (usually shown as Text Documents, Text Files
(*.txt), or something similar in the dialogue box). Be careful not to save it just yet
though if you are using Windows. Windows will save it as test.htm.txt by
default.
If you have a Mac, the way to do this will depend on your text editor.
Something similar to the methods above should work for you. If someone
with a Mac would like to write up something in more detail about this (as I
don't have a Mac), feel free to send it to me.
Now you can see above given text.html file on the desktop.
Once the page is displayed, you will see something like the following:
<html>
<head>
<title>Hello Mayura!!!!!!!</title>
</head
<body>
</body>
</html>
<html>
<body>
<h1>This is a heading</h1>
<h2>This is a heading</h2>
<h3>This is a heading</h3>
<h4>This is a heading</h1>
<h5>This is a heading</h2>
Page 4 NADISHAN MAYURA
(SCJP,SCWCD,HNDE(ELECTRONIC),BIT(colombo))
<h6>This is a heading</h3>
</body>
</html>
<html>
<body>
</body>
</html>
HTML Links
• HTML links are defined with the <a> tag.
<html>
<body>
</body>
</html>
HTML Comments
Comments can be inserted in the HTML code to make it more readable and
understandable. Comments are ignored by the browser and are not displayed.
<html>
<body>
<!--This comment will not be displayed-->
<html>
<body>
</body>
</html>
The <br /> element is an empty HTML element. It has no end tag.
<html>
<body>
<form action="hello">
First name: <input type="text" name="firstname"><br>
Last name: <input type="text" name="lastname">
</form>
2. Password fields
<html>
<body>
<form action="">
Username: <input type="text" name="user"><br>
Password: <input type="password" name="password">
</form>
<p>
Note that when you type characters in a password field, the
browser displays asterisks or bullets instead of the characters.
</p>
</body>
</html>
3. Checkboxes
<html>
<body>
<form action="">
I have a bike:
<input type="checkbox" name="vehicle"
value="Bike"><br />
I have a car:
4.Radiobuttons
<html>
<body>
<form action="">
Male:
<input type="radio" checked="checked" name="Sex"
value="male"><br>
Female:
<input type="radio" name="Sex" value="female">
</form>
<p>
When a user clicks on a radio-button, the button becomes checked,
and all other buttons with the same name become unchecked
</p>
</body>
<html>
<body>
<form action="">
<select name="names">
<option value="mayura">Mayura</option>
<option value="nadishan">Nadishan</option>
<option value="lakmal">Lakmal</option>
<option value="dinesha">Dinesha</option>
</select>
</form>
</body>
</html>
7. Create a button
<html>
<body>
<form action="">
<input type="submit" value="SUBMIT"> <br/>
<input type="button" value="Click Me!">
</form>
</body>
</html>
<html>
<body>
<form action="hello">
input your Name :<input type="text" name="mayura">
<br/>
Input your Password :<input type="password"
name="password"><br/>
<input type="submit" value="SUBMIT">
</form>
</body>
</html>
<fieldset>
<legend>
Your Information:
</legend>
<form action="">
Name <input type="text" size="2">
Address <input type="text" size="3">
Age <input type="text" size="4">
E-mail <input type="text" size="5">
</form>
</fieldset>
<p>
If there is no border around the input form, your browser is too old.
</p>
</body>
</html>
<p>
If you click the "Submit" button, you will send your input to a new page
called HelloWorld.html.
</p>
</body>
</html>
<html>
<body>
<html>
<body>
<FORM METHOD=POST ENCTYPE="multipart/form-data"
action="A.Html">
File to upload: <INPUT TYPE=FILE NAME="upfile"><br/>
<INPUT TYPE=SUBMIT VALUE="Submit">
</FORM>
</body>
</html>
• If you use “Google Chrome” to check it out you may see following
figure.
<html>
<body>
<p>
Each table starts with a table tag. Each table row starts with a
tr tag. Each table data starts with a td tag.
</p>
<h4>One column:</h4>
<table border="1">
<tr>
<td>100</td>
</tr>
</table>
</body>
</html>
2. Headings in a table
<html>
<body>
<h4>Table headers:</h4>
<table border="1">
<tr>
<th>Name</th>
<h4>Vertical headers:</h4>
<table border="1">
<tr>
<th>First Name:</th>
<td>Nadishan</td>
</tr>
<tr>
<th>Telephone:</th>
<td>0775139875</td>
</tr>
<tr>
<th>Telephone:</th>
<td>0775139876</td>
</tr>
</table>
</body>
</html>
<html>
<body>
<h4>
This table has a caption,and a thick border:
</h4>
<table border="6">
<caption>My Caption</caption>
<tr>
<td>100</td>
<td>200</td>
<td>300</td>
</tr>
<tr>
<td>400</td>
<td>500</td>
<td>600</td>
</tr>
</table>
</body>
</html>
</body>
</html>
<table border="1">
<tr>
<td>
<p>This is a paragraph</p>
<p>This is another paragraph</p>
</td>
<td>This cell contains a table:
<table border="1">
<tr>
<td>A</td>
<td>B</td>
</tr>
<tr>
<td>C</td>
<td>D</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>This cell contains a list
<ul>
<li>apples</li>
<li>bananas</li>
<li>pineapples</li>
</ul>
</td>
<td>HELLO</td>
</tr>
</table>
6.
Cell padding (control the white space between cell
content and the borders
<html>
<body>
<h4>Without cellpadding:</h4>
<table border="1">
<tr>
<td>First</td>
<td>Row</td>
</tr>
<tr>
<td>Second</td>
<td>Row</td>
</tr>
</table>
<h4>With cellpadding:</h4>
<table border="1"
cellpadding="10">
<tr>
</body>
</html>
<h4>Without cellspacing:</h4>
<table border="1">
<tr>
<td>First</td>
<td>Row</td>
</tr>
<tr>
Page 23 NADISHAN MAYURA
(SCJP,SCWCD,HNDE(ELECTRONIC),BIT(colombo))
<td>Second</td>
<td>Row</td>
</tr>
</table>
<h4>With cellspacing:</h4>
<table border="1"
cellspacing="10">
<tr>
<td>First</td>
<td>Row</td>
</tr>
<tr>
<td>Second</td>
<td>Row</td>
</tr>
</table>
</body>
</html>
<html>
<body>
</body>
</html>
<html>
<body>
<h4>Cell backgrounds:</h4>
<table border="1">
<tr>
<td bgcolor="red">First</td>
<td>Row</td>
</tr>
<tr>
<td
background="bgdesert.jpg">
Second</td>
<td>Row</td>
</tr>
</table>
</body>
</html>
<html>
<body>
<table width="400" border="1">
<tr>
<th align="left">Money spent on....</th>
<th align="right">January</th>
<th align="right">February</th>
</tr>
<tr>
<td align="left">Clothes</td>
<td align="right">$241.10</td>
<td align="right">$50.20</td>
</tr>
<tr>
<td align="left">Make-Up</td>
<td align="right">$30.00</td>
<td align="right">$44.45</td>
</tr>
<tr>
<td align="left">Food</td>
<td align="right">$730.40</td>
<td align="right">$650.00</td>
</tr>
<tr>
<th align="left">Sum</th>
<th align="right">$1001.50</th>
<th align="right">$744.65</th>
</tr>
</table>
11
The frame attribute
<html>
<body>
<p>
If you see no frames around the tables in these examples, your browser is too
old, or does not support it.
</p>
<h4>With frame="border":</h4>
<table frame="border">
<tr>
<td>First</td>
<td>Row</td>
</tr>
<tr>
<td>Second</td>
<td>Row</td>
</tr>
</table>
<h4>With frame="box":</h4>
<table frame="box">
<tr>
<h4>With frame="void":</h4>
<table frame="void">
<tr>
<td>First</td>
<td>Row</td>
</tr>
<tr>
<td>Second</td>
<td>Row</td>
</tr>
</table>
<h4>With frame="above":</h4>
<table frame="above">
<tr>
<td>First</td>
<td>Row</td>
</tr>
<tr>
<td>Second</td>
<td>Row</td>
</tr>
</table>
<h4>With frame="below":</h4>
<table frame="below">
<tr>
<td>First</td>
<td>Row</td>
</tr>
<tr>
<td>Second</td>
<td>Row</td>
</tr>
<h4>With frame="hsides":</h4>
<table frame="hsides">
<tr>
<td>First</td>
<td>Row</td>
</tr>
<tr>
<td>Second</td>
<td>Row</td>
</tr>
</table>
<h4>With frame="vsides":</h4>
<table frame="vsides">
<tr>
<td>First</td>
<td>Row</td>
</tr>
<tr>
<td>Second</td>
<td>Row</td>
</tr>
</table>
<h4>With frame="lhs":</h4>
<table frame="lhs">
<tr>
<td>First</td>
<td>Row</td>
</tr>
<tr>
<td>Second</td>
<td>Row</td>
</tr>
</table>
<h4>With frame="rhs":</h4>
<table frame="rhs">
<tr>
<td>First</td>
<td>Row</td>
</body>
</html>
<html>
<body>
<p>
If you see no frames around the tables in these examples, your browser does not
support the frame attribute.
</p>
</body>
</html>