Friday, 23 January 2015

Basic Programs of HTML

EXAMPLE 1, A VERY SIMPLE HTML DOCUMENT
<html>
<body>
The content of the body element is displayed in your browser.
</body>
</html>

EXAMPLE 2, GIVING COMMENTS
<html>
<body>
<!--This comment will not be displayed-->
This is a regular paragraph </body>
</html>

EXAMPLE 3, SIMPLE PARAGRAPH TAG
<html>
<body>
<p>This is a paragraph.
<p>This is a paragraph.
<p>This is a paragraph.
<p>Paragraph elements are defined by the p tag.
</body>
</html>

EXAMPLE 4, PARAGRAPH WITH MULITPLE LINES IN THE SOURCE CODE
<html>
<body>
<p>
This paragraph
contains a lot of lines
in the source code,
but the browser
ignores it. </p>
<p> This paragraph contains a lot of spaces in the
source code, but the browser
ignores it. </p> <p>
The number of lines in a paragraph depends on the size
of your browser window. If you resize the browser
window,
the number of lines in this paragraph will change. </p>
</body>
</html>

EXAMPLE 5, PROBLEMS WITH HTML SPACING
<html> <body> <p>
My Bonnie lies over the ocean.
My Bonnie lies over the sea.
My Bonnie lies over the ocean.
Oh, bring back my Bonnie to me. </p>
<p>Note that your browser simply ignores your formatting!</p>
</body>
</html>

EXAMPLE 6, PREFORMATTED TAG
<html>
<body>
<pre>   This is preformatted text.
It preserves both spaces and line breaks. </pre>
<p>The pre tag is good for displaying computer code:</p> <pre>
for i = 1 to 10
print i
next i
</pre> </body> </html>

EXAMPLE 7, LINE BREAKS ON WEB PAGE
<html>
<body>
<p> To break<br>lines<br>in a<br>paragraph,<br>use the br tag.
</p>
</body>
</html>
EXAMPLE 8, HTML HEADINGS
<html>
<body>
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>
<p>Use heading tags only for headings. Don't use them to make something big. Use other tags for that.</p>
</body>
</html>

EXAMPLE 9, CENTRALISED HEADING
<html>
<body>
<h1 align="center">This is heading 1</h1>
<p>The heading above is aligned to the center of this page. The heading above is aligned to the center of this
page. The heading above is aligned to the center of this page.</p>
</body>
</html>

EXAMPLE 10 GIVING HORIZONTAL LINE ON A WEB PAGE
<html>
<body>
<p>The hr tag defines a horizontal rule:</p>
<hr>
<p>This is a paragraph</p>
<hr>
<p>This is a paragraph</p>
<hr>
<p>This is a paragraph</p>
</body>
</html>

EXAMPLE 11, ADD A BACKGROUND COLOR
<html>
<body bgcolor="yellow">
<h3>Look: Colored Background!</h3>
</body>
</html>

EXAMPLE 12, ADD A BACKGROUND COLOR
<html>
<body bgcolor="#d0d0d0">
<p>
This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.
</p>
<p>
This is another paragraph. This is another paragraph. This is another paragraph. This is another paragraph.
</p>
</body>
</html>

EXAMPLE 13, ADD A BACKGROUND IMAGE
<html>
<body background="background.jpg">
<h3>Look: Image Background!</h3>
<p>Both gif and jpg files can be used as HTML backgrounds.</p>
<p>If the image is smaller than the page, the image will repeat itself.</p>
</body>
</html>

EXAMPLE 14 TEXT FORMATTING
<html>
<body>
<b>This text is bold</b> <br>
<strong> This text is strong </strong>
<br> <big> This text is big </big>
<br> <em> This text is emphasized </em>
<br> <i> This text is italic </i> <br> <small>
This text is small </small> <br>
This text contains <sub> subscript
</sub> <br>
This text contains
<sup>
superscript
</sup>
</body>
</html>

EXAMPLE 15 INSERT IMAGE
<html>
<body>
<img src="../images/goleft.gif" alt="Go Left" width="32" height="32">
<p>
Text-only browsers will only display the text in the "alt" attribute, which is "Go Left".
Note that if you hold the mouse pointer over the image it will display the text.
</p>
</body>
</html>

EXAMPLE 16 ADJUST IMAGES TO DIFFERENT SIZES
<html>
<body>
<p>
<img src="../images/hackanm.gif" width="20" height="20">
</p>
<p>
<img src="../images/hackanm.gif" width="45" height="45">
</p>
<p>
<img src="../images/hackanm.gif" width="70" height="70">
</p>
<p> You can make a picture larger or smaller changing the values in the "height" and "width" attributes of the
<img> tag. </p>
</body>
</html>

EXAMPLE 17, WORKING WITH IMAGES FROM DIFFERENT FOLDER
<html>
<body>
<p>
An image from another folder:
<img src="../images/netscape.gif" width="33" height="32">
</p>
<p>
An image from W3Schools:
<img src="http://www.w3schools.com/images/ie.gif" width="73" height="68">
</p>
</body>
</html>

EXAMPLE 18, WORKING WITH MOVING IMAGES
<html>
<body>
<p>
An image:
<img src="constr4.gif" width="144" height="50">
</p>
<p>
A moving image:
<img src="hackanm.gif" width="48" height="48">
</p>
<p>
Note that the syntax of inserting
a moving image, is no different from
a non-moving image.
</p>
</body>
</html>

EXAMPLE 19, DISPLAY AN ALTERNATE TEXT FOR AN IMAGE
<html>
<body>
<img src="../images/goleft.gif" alt="Go Left" width="32" height="32">
<p>
Text-only browsers will only display the text in the "alt" attribute, which is "Go Left".
Note that if you hold the mouse pointer over the image it will display the text.
</p>
</body>
</html>

EXAMPLE 20, HOW TO CREATE HYPERLINKS
<html>
<body>
<p>
<a href="lastpage.htm">
This text</a> is a link to a page on
this Web site.
</p>
<p>
<a href="http://www.microsoft.com/">
This text</a> is a link to a page on
the World Wide Web.
</p>
</body>
</html>

EXAMPLE 21, SET AN IMAGE AS A LINK
<html>
<body>
<p>
You can also use an image as a link:
<a href="lastpage.htm">
<img border="0" src="buttonnext.gif" width="65" height="38">
</a>
</p>
</body>
</html>

EXAMPLE 22, OPEN A LINK IN A NEW BROWSER WINDOW
<html>
<body>
<a href="lastpage.htm" target="_blank">Last Page</a>
<p>
If you set the target attribute of a link to "_blank",
the link will open in a new window.
</p>
</body>
</html>

EXAMPLE 23, JUMPING TO ANOTHER PART OF A DOCUMENT IN THE SAME PAGE
<html>
<body>
<p>
<a href="#C4">
See also Chapter 4.
</a>
</p>
<p>
<h2>Chapter 1</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 2</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 3</h2>
<p>This chapter explains ba bla bla</p>
<a name="C4"><h2>Chapter 4</h2></a>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 5</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 6</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 7</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 8</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 9</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 10</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 11</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 12</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 13</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 14</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 15</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 16</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 17</h2>
<p>This chapter explains ba bla bla</p>
</body>
</html>

EXAMPLE 24, HOW TO LINK TO A MAIL MESSAGE
<html>
<body>
<p>
This is a mail link:
<a href="mailto:someone@microsoft.com?Subject=Hello again">
Send Mail</a>
</p>
</body>
</html>

EXAMPLE 25, SIMPLE UNORDERED LIST
<html>
<body>
<h4>An Unordered List:</h4>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
</body>
</html>

EXAMPLE 26, NESTED UNORDERED LIST
<html>
<body>
<h4>A nested List:</h4>
<ul>
<li>Coffee</li>
<li>Tea
<ul>
<li>Black tea</li>
<li>Green tea</li>
</ul>
</li>
<li>Milk</li>
</ul>
</body>
</html>
<html>
<body>

EXAMPLE 27, BULLETED LIST
<html>
<body>
<h4>Disc bullets list:</h4>
<ul type="disc">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
</ul>
<h4>Circle bullets list:</h4>
<ul type="circle">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
</ul>
<h4>Square bullets list:</h4>
<ul type="square">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
</ul>
</body>
</html>

EXAMPLE 28, AN ORDERED LIST
<html>
<body>
<h4>An Ordered List:</h4>
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
</body>
</html>

EXAMPLE 29, A NUMBERED LIST
<html>
<body>
<h4>Numbered list:</h4>
<ol>
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
</ol>
<h4>Letters list:</h4>
<ol type="A">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
</ol>
<h4>Lowercase letters list:</h4>
<ol type="a">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
</ol>
<h4>Roman numbers list:</h4>
<ol type="I">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
</ol>
<h4>Lowercase Roman numbers list:</h4>
<ol type="i">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
</ol>
</body>
</html>

EXAMPLE 30, A DEFINITION LIST
<html>
<body>
<h4>A Definition List:</h4>
<dl>
<dt>Coffee</dt>
<dt>Milk</dt>
<dd>White cold drink</dd>
</dl>
</body>
</html>

EXAMPLE 31, SIMPLE TABLES
<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>
<h4>One row and three columns:</h4>
<table border="1"> <tr>
<td>100</td> <td>200</td> <td>300</td>
</tr> </table>
<h4>Two rows and three columns:</h4>
<table border="1">
<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>

EXAMPLE 32, DIFFERENT TABLE BORDERS
<html>
<body>
<h4>With a normal border:</h4>
<table border="1">
<tr> <td>First</td> <td>Row</td> </tr>
<tr> <td>Second</td> <td>Row</td>
</tr>
</table> <h4>With a thick border:</h4>
<table border="8"> <tr> <td>First</td> <td>Row</td>
</tr> <tr> <td>Second</td> <td>Row</td> </tr> </table>
<h4>With a very thick border:</h4>
<table border="15"> <tr> <td>First</td> <td>Row</td>
</tr> <tr> <td>Second</td> <td>Row</td> </tr>
</table>
</body>
</html>

EXAMPLE 33, TABLE WITH NO BORDERS
<html>
<body>
<h4>This table has no borders:</h4>
<table>
<tr> <td>100</td> <td>200</td> <td>300</td> </tr>
<tr> <td>400</td> <td>500</td> <td>600</td> </tr>
</table> <h4>And this table has no borders:</h4>
<table border="0"> <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>

EXAMPLE 34, HEADINGS IN A TABLE
<html>
<body>
<h4>Table headers:</h4>
<table border="1">
<tr> <th>Name</th> <th>Telephone</th> <th>Telephone</th>
</tr> <tr> <td>Bill Gates</td> <td>555 77 854</td> <td>555 77 855</td>
</tr> </table> <h4>Vertical headers:</h4> <table border="1">
<tr> <th>First Name:</th> <td>Bill Gates</td> </tr> <tr>
<th>Telephone:</th> <td>555 77 854</td> </tr> <tr>
<th>Telephone:</th> <td>555 77 855</td> </tr> </table>
</body>
</html>

EXAMPLE 35, TABLE WITH EMPTY CELLS
<html> <body>
<table border="1">
<tr> <td>Some text</td> <td>Some text</td> </tr>
<tr> <td></td> <td>Some text</td> </tr> </table>
<p> As you can see, one of the cells has no border. That is because it is empty. Try to insert a space in the
cell. Still it has no border. </p>
<p> The trick is to insert a no-breaking space (&nbsp;) in the cell. No-breaking space is a character entity. If
you don't know what a character entity is, read the chapter about it.
</body>
</html>
EXAMPLE 36, TABLE CELL SPANS MORE THAN ONE ROW OR COLUMN
<html> <body>
<h4>Cell that spans two columns:</h4>
<table border="1"> <tr>
<th>Name</th> <th colspan="2">Telephone</th>
</tr> <tr> <td>Bill Gates</td>
<td>555 77 854</td> <td>555 77 855</td> </tr> </table>
<h4>Cell that spans two rows:</h4> <table border="1"> <tr>
<th>First Name:</th> <td>Bill Gates</td> </tr> <tr> <th rowspan="2">Telephone:</th>
<td>555 77 854</td> </tr> <tr> <td>555 77 855</td> </tr>
</table>
</body>
</html>

EXAMPLE 37, TAGS INSIDE TABLE
<html>
<body>
<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> </td> </tr>
</table>
</body>
</html>

EXAMPLE 38, CELL PADDING THE WHITE SPACE BETWEEN CELL CONTENT AND THE BORDER
<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>
<td>First</td> <td>Row</td> </tr> <tr> <td>Second</td> <td>Row</td>
</tr>
</table>
</body>
</html>

EXAMPLE 39, CELL SPACING - CONTROL THE DISTANCE BETWEEN CELLS
<html> <body> <h4>Without cellspacing:</h4>
<table border="1"> <tr> <td>First</td> <td>Row</td>
</tr> <tr> <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>

EXAMPLE 40, ALIGN THE CONTENT IN A TABLE CELL
<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>
</body>
</html>


EXAMPLE 41, ADD A BACKGROUND COLOR OR A BACKGROUND IMAGE TO A TABLE CELL
<html>
<body>
<h4>Cell backgrounds:</h4>
<table border="1"> <tr>
<td bgcolor="red">First</td>
<td>Row</td> </tr> <tr> <td
background="../images/bgdesert.jpg">
Second</td> <td>Row</td> </tr>
</table>
</body>
</html>

EXAMPLE 42, HOW TO CREATE INPUT FIELD
<html>
<body>
<form>
First name: <input type="text" name="firstname"> <br> Last name:
<input type="text" name="lastname">
</form>
</body>
</html>

EXAMPLE 43, HOW TO CREATE PASSWORD FIELD
<html>
<body>
<form> 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>

EXAMPLE 44, HOW TO CREATE MULTILINE INPUT FIELD
<html>
<body> <p> This example can not be edited because our editor uses a textarea
for input, and your browser does not allow a textarea inside a textarea. </p>
<textarea rows="10" cols="30"> The cat was playing in the garden.
</textarea>
</body>
</html>
EXAMPLE 45, HOW TO USE CHECK BOXES
<html>
<body>
<form> I have a bike: <input type="checkbox"
name="Bike">
<br> I have a car: <input type="checkbox" name="Car">
</form>
</body>
</html>

EXAMPLE 46, HOW TO USE RADIO BUTTONS ON A FORM
<html>
<body>
<form> Male: <input type="radio" checked name="Sex"> <br>
Female: <input type="radio" name="Sex">
</form>
<p>
When a user clicks on a radio-button, the button becomes checked, and all other buttons with the same name
becomes unchecked </p>
</body>
</html>

EXAMPLE 47, HOW TO CREATE SIMPLE DROP-DOWN LIST
<html>
<body>
<form>
<select name="COURSE">
<option value="DIT">DIT
<option value="CIT">CIT
<option value="SHORTCOURE">SHORTCOURSE
<option value="MCSE">MCSE
</select>
</form>
</body>
</html>

EXAMPLE 48, HOW TO CREATE DROP-DOWN BOX WITH PRE-SELECTED VALUE
<html>
<body>
<form>
<select name="COURSE">
<option value="DIT">DIT
<option value="CIT">Saab
<option value="MCITP" selected>MCITP <option value="SHORTCOURSE">SHORTCOURSE </select>
</form>
</body>
</html>

EXAMPLE 49, HOW TO CREATE PUSH BUTTONS
<html>
<body>
<form name="input" action="html_form_action.asp" method="get">
Enter your first name:
<input type="text" name="FirstName" value="Mickey">
<br>Enter your last name:
<input type="text" name="LastName" value="Mouse">
<br>
<input type="submit" value="Submit">
</form>
<p>
If you click the "Submit" button, you will send your input to a new page called html_form_action.asp.
</p>
</body>
</html>

EXAMPLE 50, HOW TO DRAW A BORDER WITH A CAPTION AROUND DATA
<html>
<body>
<fieldset>
<legend>
Health information:
</legend>
<form>
Height <input type="text" size="3">
Weight <input type="text" size="3">
</form>
</fieldset>
<p>
If there is no border around the input form, your browser is too old.
</p>
</body>
</html>

EXAMPLE 51, SOURCE CODE OF NAVIGATION FRAME
<html>
<body>
<a href ="framea.htm" target ="showframe">Frame&nbsp; a</a><br>
<a href ="frameb.htm" target ="showframe">Frame&nbsp; b</a><br>
<a href ="framec.htm" target ="showframe">Frame&nbsp; c</a>
</body>
</html>
<!--Code of Frame A -->
<html>
<body bgcolor="#8F8FBD">
<h3>Frame A</h3>
</body>
</html>
<!--Code of frameB -->
<html>
<body bgcolor="#EBC79E">
<h3>Frame B</h3>
</body>
</html>
<!--Source code of frame C -->
<html>
<body bgcolor="#FFFFCC">
<h3>Frame C</h3>
</body>
</html>

EXAMPLE 52, HTML FILE FOR CREATING FRAME FOR NAVIGATION

<html>
<frameset cols="120,*">
<frame src="framea.htm">
<frame src="frameb.htm" name="showframe">
</frameset>
</html>
















No comments:

Post a Comment

Download Basic Concepts of I.T

To download Basic Concepts of Information Technology  Click Here