Anda di halaman 1dari 22

HTML is a language for describing web pages.

HTML stands for Hyper Text Markup Language HTML is not a programming language, it is a markup language A markup language is a set of markup tags HTML uses markup tags to describe web pages

<html> <body> <h1>My First Heading</h1> <p>My first paragraph</p> </body> </html>

Example Explained

The text between <html> and </html> describes the web page The text between <body> and </body> is the visible page content The text between <h1> and </h1> is displayed as a heading The text between <p> and </p> is displayed as a paragraph

<html><head> </head><body> <h1>This is my Main Page</h1> <p>This is some text.</p> <p><a href="page1.htm">This is a link to Page 1</a></p> <p><a href="page2.htm">This is a link to Page 2</a></p> </body></html>

o/p

This is my Main Page


This is some text. This is a link to Page 1

This is a link to Page 2

1.HTML HEADING <h1>This is a heading</h1> <h2>This is a heading</h2> <h3>This is a heading</h3> 2. HTML PARAGRAPHS == <p>This is a paragraph</p> <p>This is another paragraph</p>

3.HTML LINKS ==== <a href="http://www.w3schools.com">This is a link</a> 4.HTML IMAGES == <img src="w3schools.jpg" width="104" height="142" />

Start tag * <p> <a href="default.htm" > <br />

Element content This is a paragraph This is a link

End tag * </p> </a>

<br> is an empty element without a closing tag (it defines a line break). In XHTML, XML, and future versions of HTML, all elements must be closed. Adding a slash to the start tag, like <br />, is the proper way of closing empty elements, accepted by HTML, XHTML and XML. Even if <br> works in all browsers, writing <br /> instead is more future proof.

@ HTML tags are not case sensitive: <P> means the same as <p>. Plenty of web sites use uppercase HTML tags in their pages. @ Attribute values should always be enclosed in quotes. Below is a list of some attributes that are standard for most HTML elements: Attribute class id Value class_rule or style_rule id_name Description The class of the element A unique id for the element

style title

style_definition tooltip_text

An inline style definition A text to display in a tool tip

@ COMMENT == <!-- This is a comment --> You will learn more about HTML tags and attributes in the next chapters of this tutorial. Tag <html> <body> <h1> to <h6> <hr /> <!--> Description Defines an HTML document Defines the document's body Defines header 1 to header 6 Defines a horizontal rule Defines a comment

HTML LINE BREAKS

<p>This is<br />a para<br />graph with line breaks</p> @@@@@@@@@@@@@@@@@@@@@@@@

HTML TEXT FORMATTING <html> <body> <p><b>This text is bold</b></p> <p><big>This text is big</big></p> <p><i>This text is italic</i></p> <p><code>This is computer output</code></p> <p>This is<sub> subscript</sub> and <sup>superscript</sup></p> </body> </html>

O/P= This text is bold

This text is big


This text is italic

This is computer output

This is subscript and superscript


@@ PREFORMATTED TAG <pre> Defines preformatted text eg. <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>

O/P
This is preformatted text. It preserves both spaces and line breaks.

The pre tag is good for displaying computer code:


for i = 1 to 10 print i next i

@@ <code> Defines computer code text ,<kbd> Defines keyboard text, <samp> Defines sample computer code, <tt> Defines teletype text , <var> Defines a variable <html> <body> <code>Computer code</code> <br>

<kbd>Keyboard input</kbd> <br> <tt>Teletype text</tt> <br> <samp>Sample text</samp> <br> <var>Computer variable</var> <br> <p> <b>Note:</b> These tags are often used to display computer/programming code. </p> </body> </html> O/P = Computer code
Keyboard input Teletype text

Sample text Computer variable Note: These tags are often used to display computer/programming code.

@@ ADDRESS @ <html> <body> <address> Donald Duck<br> BOX 555<br> Disneyland<br> USA </address> </body> </html> O/P == Donald Duck BOX 555 Disneyland USA

@@ABBEREVATIONS @<abbr> Defines an abbreviation , <acronym> Defines an acronym <abbr title="United Nations">UN</abbr> <br /> <acronym title="World Wide Web">WWW</acronym>

O/P == UN WWN

TEXT DIRECTION @@ <bdo> Defines the text direction ,,, rtl= RIGHT TO LEFT <bdo dir="rtl"> Here is some Hebrew text</bdo> Eg. Here is some Hebrew text

@@ <blockquote> Defines a long quotation <q> Defines a short quotation A blockquote quotation: <blockquote> This is a long quotation. This is a long quotation. This is a long quotation. This is a long quotation. This is a long quotation. </blockquote>

<p><b>The browser inserts line breaks and margins for a blockquote element.</b></p>

A short quotation: <q>This is a short quotation</q> O/P

This is a long quotation. This is a long quotation. This is a long quotation. This is a long quotation. This is a long quotation. The browser inserts line breaks and margins for a blockquote element.

A short quotation: This is a short quotation @@@@@@@@@@@


<ins> Defines inserted text <p> a dozen is <del>twenty</del> <ins>twelve</ins> pieces </p> ==== <del> Defines deleted text

a dozen is twenty twelve pieces

Text Formatting Tags


Tag <b> <big> <em> <i> <small> <strong> <sub> <sup> <ins> <del> <s> <strike> <u> Description Defines bold text Defines big text Defines emphasized text Defines italic text Defines small text Defines strong text Defines subscripted text Defines superscripted text Defines inserted text Defines deleted text Deprecated. Use <del> instead Deprecated. Use <del> instead Deprecated. Use styles instead

Computer Output" Tags


Tag <code> <kbd> Description Defines computer code text Defines keyboard text

<samp> <tt> <var> <pre> <listing> <plaintext> <xmp>

Defines sample computer code Defines teletype text Defines a variable Defines preformatted text Deprecated. Use <pre> instead Deprecated. Use <pre> instead Deprecated. Use <pre> instead

Citations, Quotations, and Definition Tags


Tag <abbr> <acronym> <address> <bdo> <blockquote> <q> <cite> <dfn> Description Defines an abbreviation Defines an acronym Defines an address element Defines the text direction Defines a long quotation Defines a short quotation Defines a citation Defines a definition term

@@@@@@@@@@@@@@@@@@@@@@@

HTML Style Examples


style="background-color:yellow" style="font-size:10px" style="font-family:Times" style="text-align:center"

These tags and attributes should be avoided: Tags <center> Description Defines centered content

<font> and <basefont> <s> and <strike> <u> Attributes align bgcolor color

Defines HTML fonts Defines strikeout text Defines underlined text Description Defines the alignment of text Defines the background color Defines the text color

@<body bgcolor="yellow">

<h2>Look: Colored Background!</h2>

FONTS <p><font size="2" face="Verdana"> This is a paragraph. </font></p>

<p><font size="5" face="Times" color="red"> This is another paragraph. </font></p> ==


This is a paragraph.

This is another paragraph.


@@ TEXT ALIGNMENT <h1 align="center">This is heading 1</h1>

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

HTML LINKS

<p> <a href="lastpage.htm"> This text</a> is a link to a page on this Web site. </p> O/P== This text is a link to a page on this Web site.

@ TO OPEN LINK IN NEW WINDOW <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>

@@LINK TO LOCATN 2 THE SAME PAGE <p> <a href="#C4">See also Chapter 4.</a> </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> <h2><a name="C4">Chapter 4</a></h2>

<p>This chapter explains ba bla bla</p>

<h2>Chapter 5</h2> <p>This chapter explains ba bla bla</p> O/P

See also Chapter 4.

Chapter 1
This chapter explains ba bla bla

Chapter 2
This chapter explains ba bla bla

Chapter 3
This chapter explains ba bla bla

Chapter 4
This chapter explains ba bla bla

@ BREAK OUT OF FRAME <p>Locked in a frame?</p>

<a href="http://www.w3schools.com/" target="_top">Click here!</a> O/P

Locked in a frame? Click here!

@@@@@@@@@@@@@@@@@@@@@@@@

HTML IMAGES
<h2>Norwegian Mountain Trip</h2> <img border="0" src="/images/pulpit.jpg" width="304" height="228" /> @ <p> An image: <img src="constr4.gif" width="144" height="50" /> </p> @INSERT IMAGES 4M DIFF LOCATN <p>An image from another folder:</p> <img src="/images/chrome.gif" width="33" height="32" /> @ ALT ATTRIBUTE

<img src="boat.gif" alt="Big Boat" /> The "alt" attribute tells the reader what he or she is missing on a page if the browser can't load images. The browser will then display the alternate text instead of the image. It is a good practice to include the "alt" attribute for each image on a page, to improve the display and usefulness of your document for people who have text-only browsers. @ BACKGRND IMAGE
<body background="background.jpg"> @ ALIGN IMAGES <img src="hackanm.gif" align="bottom" width="48" height="48" />

@ ADJUST IMAGES 2DIFF SIZES <p> <img src="hackanm.gif" width="20" height="20" /> </p> <p> <img src="hackanm.gif" width="45" height="45" /> </p>

@CREATE AN IMAGE MAP

<p>Click on the sun or on one of the planets to watch it closer:</p>

<img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap" />

<map name="planetmap"> <area shape="rect" coords="0,0,82,126" alt="Sun" href="sun.htm" /> <area shape="circle" coords="90,58,3" alt="Mercury" href="mercur.htm" /> <area shape="circle" coords="124,58,8" alt="Venus" href="venus.htm" /> </map> O/P

Click on the sun or on one of the planets to watch it closer:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

HTML TABLES

<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> O/P Two rows and three columns: 100 200 300 400 500 600

@TABLE HEADING <tr> <th>Heading</th> <th>Another Heading</th> </tr> O/P

Heading Another Heading

@TABLE WID NO BORDER <table> <tr> <td>100</td> <td>200</td> <td>300</td> </tr> <tr> <td>400</td> <td>500</td> <td>600</td> </tr> </table> O/P 100 200 300 400 500 600

@table wid thick border <table border="8">

@cell THAT SPANS MORE DN 1 ROW/COLUMN <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> O/P Cell that spans two columns: Name Telephone

Bill Gates 555 77 854 555 77 855

<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> O/P

Cell that spans two rows: First Name: Bill Gates 555 77 854 Telephone: 555 77 855

@ TABLE INSIDE TABLE <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> </tr>

<td>C</td> <td>D</td> </tr> </table> <tr><td></td><td></td></tr> O/P

This is a paragraph This is another paragraph

This cell contains a table: AB C D

@ cellpadding <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> o/p Without cellpadding: First Row

Second Row With cellpadding: First Row

Second

Row

@cellspacing <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>

o/p With cellspacing: First Row

Second Row

@table bakgrnd color <table border="1" bgcolor="red"> <tr> o/p First Row

Second Row

@@@@@@@@@@@@@@@@@@@

HTML LIST

Unordered Lists
<ul> <li>Coffee</li> <li>Milk</li> </ul>

Coffee Milk

Ordered Lists
An ordered list is also a list of items. The list items are marked with numbers.

An ordered list starts with the <ol> tag. Each list item starts with the <li> tag. <ol> <li>Coffee</li> <li>Milk</li> </ol> Here is how it looks in a browser: 1. Coffee 2. Milk

Definition Lists
A definition list starts with a <dl> tag (definition list). Each term starts with a <dt> tag (definition term). Each description starts with a <dd> tag (definition description). <dl> <dt>Coffee</dt> <dd>Black hot drink</dd> <dt>Milk</dt> <dd>White cold drink</dd> </dl> Coffee Black hot drink Milk White cold drink
@@@@@@@@@@@@@@@@@@@@@@@@

HTML FRAME.
<form> First name: <input type="text" name="firstname" /> <br /> Last name: <input type="text" name="lastname" />

</form> O/P First name: Last name: 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>

How it looks in a browser:


Male Female Checkboxes

Checkboxes are used when you want the user to select one or more options of a limited number of choices.
<form> I have a bike: <input type="checkbox" name="vehicle" value="Bike" /> <br /> I have a car: <input type="checkbox" name="vehicle" value="Car" /> <br /> I have an airplane: <input type="checkbox" name="vehicle" value="Airplane" /> </form>

I have a bike: I have a car: I have an airplane:

The Form's Action Attribute and the Submit Button


When the user clicks on the "Submit" button, the content of the form is sent to the server.
<form name="input" action="html_form_submit.asp" method="get"> Username: <input type="text" name="user" /> <input type="submit" value="Submit" /> </form>

How it looks in a browser:


Username:
Submit

DROP N DOWN BOX <form action=""> <select name="cars"> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="fiat">Fiat</option> <option value="audi">Audi</option> </select> </form> O/P

@ BUTTON <form action=""> <input type="button" value="Hello world!"> </form>

Anda mungkin juga menyukai