Sie sind auf Seite 1von 48

HTML TUTORIAL

Web Application Engineering Minakshi Gujral

HTML
HYPER TEXT MARK UP LANGUAGE HTML is the lingua franca for publishing hypertext on the World Wide Web. It is a non-proprietary format based upon SGML, and can be created and processed by a wide range of tools, from simple plain text editors - you type it in from scratch- to sophisticated WYSIWYG authoring tools. HTML uses tags such as <h1> and </h1> to structure text into headings, paragraphs, lists, hypertext links etc.

STRUCTURE OF HTML DOCUMENT


<HTML> <HEAD><TITLE>HELLO CLASS HOW ARE U TODAY</TITLE></HEAD> <BODY>WE ARE LEARNING HTML </BODY> </HTML>
NOTE:SAVE IT AS T.HTML OR T.HTM AND RUN IN BROWSER WRIITNG URL (WITH PROPER PATH). Html editors: Front page 2000, Macromedia Dreamweaver, CoffeeCup HTML Editor.

BASIC HTML TUTORIAL


1. Basic Tags 2. Formatting Text 3. Links 4. Frames 5. Tables 6. Lists 7. Forms and Input 8. Images 9. Backgrounds 10. The Head Section 11. The Meta Tag 12. Scripts

Formatting Text
-Text formatting -Preformatted text (how to control line breaks and spaces) -Different computer-output tags Insert an address -Abbreviations and acronyms -Long and short quotations -How to mark deleted and inserted text

Header
<h1 align="center">>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 just to make something bold. Use other tags for that.</p> <Adding comments: <!--This comment will not be displayed--> <p>This is a regular paragraph</p> Background color and image <body bgcolor="yellow"> or <body background="background.jpg">

Basic Formatting
<b>This text is bold</b> <br> <strong> This text is strong </strong> <br> BIG<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>

preformatted text
<pre> This is preformatted text. It preserves both spaces and line breaks. </pre> <pre> for i = 1 to 10 print i next i </pre>

Different computeroutput tags


<code>Computer code</code> <br> <kbd>Keyboard input</kbd> <br> <tt>Teletype text</tt> <br> <samp>Sample text</samp>

Paragraph <p>This is a paragraph.</p> <p>This is a paragraph.</p> <p>This is a paragraph.</p> <p>Paragraph elements are defined by the p tag.</p> With break and horizontal rule <hr width=50 color=red> <p> To break<br>lines<br>in a<br>paragraph,<br>use the br tag. </p>

Definition list
<dl> <dt>First term</dt> <dd>Definition</dd> <dt>Next term</dt> <dd>Definition</dd> </dl>

-Abbreviations and acronyms


<abbr title="United Nations">UN</abbr> <br> <acronym title="World Wide Web">WWW</acronym> Note: The title attribute is used to show the spelled-out version when holding the mouse pointer over the acronym or abbreviation.</p> The title attribute is used to show the spelled-out version when holding the mouse pointer over the acronym or abbreviation. This only works for the acronym element in IE 5. This works for both the abbr and acronym element in Netscape 6.2.

How to mark deleted and inserted text


<p> a dozen is <del>twenty</del> <!strikethro--!> <ins>twelve</ins> pieces </p>

Long and short quotations


With the block quote element, the browser inserts line breaks and margins, but the q element does not render as anything special. Here comes a long 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> Here comes a short quotation: <q> This is a short quotation </q>

Lists
Lists An unordered list An ordered list Different types of ordered lists Different types of unordered Lists Nested list Nested list 2 Definition list

An ordered list
<h4>An Ordered List:</h4> <ol> <li>Coffee</li> <li>Tea</li> <li>Milk</li> </ol> By default will show 1,2,3,4

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

An unordered list
<h4>An Unordered List:</h4> <ul> <li>Coffee</li> <li>Tea</li> <li>Milk</li> </ul>

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

Links
1)<p> This is a mail link: <a href="mailto:someone@microsoft.com?subject= Hello%20again"> Send Mail</a> </p> 2)<p>Locked in a frame?</p> <a href="http://www.w3schools.com/" target="_top">Click here!</a> 3) <p> <a href="#C4"> See also Chapter 4. </a> </p> <a name="C4"><h2>Chapter 4</h2></a> <p>This chapter explains </p>

4) <a href="lastpage.htm" target="_blank">Last Page</a> 5) 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> 6) <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>

Tables

Tables are defined with the <table> tag. A table is divided into rows (with the <tr> tag), and each row is divided into data cells (with the <td> tag). The letters td stands for "table data," which is the content of a data cell. A data cell can contain text, images, lists, paragraphs, forms, horizontal rules, tables, etc.

Basic 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 2</td> </tr> </table>

Tables and the Border Attribute

<table border="1"> <tr> <td>Row 1, cell 1</td> <td>Row 1, cell 2</td> </tr> </table> Headings in a Table <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> Note: for empty space we can add <td>&nbsp;</td>

Cell padding This example demonstrates how to use cellpadding to create more white space between the cell content and its borders. See html example Cell spacing This example demonstrates how to use cellspacing to increase the distance between the cells. See html example

<h4>A background color:</h4> <table border="1" bgcolor="red"> <tr> <td>First</td> <td>Row</td> </tr> <tr> <td>Second</td> <td>Row</td> </tr> </table>

<h4>A background image:</h4> <table border="1" background="bgdesert .jpg"> <tr> <td>First</td> <td>Row</td> </tr> <tr> <td>Second</td> <td>Row</td> </tr> </table>

Adding background color and Image

Adding background to table cell


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

Table tag descritpton


<table>Defines a table <th>Defines a table header <tr>Defines a table row <td>Defines a table cell <caption>Defines a table caption <colgroup>Defines groups of table columns <col>Defines the attribute values for one or more columns in a table <thead>Defines a table head <tbody>Defines a table body <tfoot>Defines a table footer

Frame
With 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 web developer must keep track of more HTML documents It is difficult to print the entire page The Frameset Tag 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

Frame
1) 2) 3) 4) 5) 6) 7)
Vertical Frame example Horizontal Frame example No Frame Frameset with noresize="noresize Navigation frame Inline frame example Jump to a specified section within a frame example 8) Jump to a specified section with frame navigation example

No frame
<html> <frameset cols="25%,50%,25%"> <frame src="frame_a.htm"> <frame src="frame_b.htm"> <frame src="frame_c.htm"> <noframes> <body>Your browser does not handle frames!</body> </noframes> </frameset> </html>

noresize
<frameset rows="50%,50%"> <frame noresize="noresize" src="frame_a.htm"> <frameset cols="25%,75%"> <frame noresize="noresize" src="frame_b.htm"> <frame noresize="noresize" src="frame_c.htm"> </frameset>

Fonts
Note: The <font> tag in HTML is deprecated. It is supposed to be removed in a future version of HTML. 1><p> <font size="2" face="Verdana color=red> This is a paragraph. </font> </p><p> <font size="3" face="Times"> This is another paragraph. </font> </p> 2><h1 style="color:blue">A heading</h1> <p style="color:red">A paragraph</p> 3><p style="font-family:verdana;fontsize:80%;color:green"> This is a paragraph with some text in it.</p>

size="number" size="2" Defines the font size size="+number" size="+1" Increases the font size size="-number" size="-1" Decreases the font size face="face-name" face="Times" Defines the font-name color="color-value" color="#eeff00" Defines the font color color="color-name" color="red" Defines the font color

Font Attributes

Basic Form
HTML Forms are used to select different kinds of user input
A form is an area that can contain form elements. Form elements are elements that allow the user to enter information (like text fields, textarea fields, drop-down menus, radio buttons, checkboxes, etc.) in a form.

A form is defined with the <form> tag. <form> <input> <input> </form>

Text Fields <form> First name: <input type="text" name=f1"> <br> Last name: <input type="text" name=l1"> </form> RADIO BUTTONS <input type="radio" name="sex" value="male"> Male <br> <input type="radio" name="sex" value="female"> Female CHECKBOX <input type="checkbox" name="bike"> I have a bike <br> <input type="checkbox" name="car"> I have a car

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 another file. The form's action attribute defines the name of the file to send the content to. The file defined in the action attribute usually does something with the received input. <form name="input" action="html_form_action.asp" method="get"> Username: <input type="text" name="user"> <input type="submit" value="Submit"> </form> Some examples of Forms: 1, 2, 3

Form Tags Description <form>Defines a form for user input <input>Defines an input field <textarea>Defines a text-area (a multi-line text input control) <label>Defines a label to a control <fieldset>Defines a fieldset <legend>Defines a caption for a fieldset <select>Defines a selectable list (a drop-down box) <optgroup>Defines an option group <option>Defines an option in the drop-down box <button>Defines a push button <isindex> Deprecated. Use <input> instead

The Alt Attribute The alt attribute is used to define an "alternate text" for an image. The value of the alt attribute is an author-defined text: <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.

The Meta Element the head element contains general information (meta-information) about a document. 1. Document descriptionInformation inside a meta element describes the document. 2. Document keywords Information inside a meta element describes the document's keywords. 3. Redirect a userThis example demonstrates how to redirect a user if your site address has changed. HTML also includes a meta element that goes inside the head element. The purpose of the meta element is to provide meta-information about the document. Most often the meta element is used to provide information that is relevant to browsers or search engines like describing the content of your document.

Entities &lt; is the same as < &gt; is the same as > &#169; is the same as http://www.w3schools.com/html/html_ref erence.asp- note: gives list of tags in form of table and their suitability to specific browser version.

Html webserver
Personal Web Server (PWS) 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.

HTML Advanced
HTML Layout HTML Fonts HTML 4.0 Why HTML Styles HTML Head HTML Meta HTML URLs HTML Scripts HTML Web server

HTML Tags
LETS SEE WORKABLE BASIC HTML CODE IN AN ONLINE CLASSROOM

NOTE: IF THIS LINK DO NOT WORK TYPE: http://www.w3schools.com/html/html_examples. asp

WEB REFERENCES FOR HTML:

1. http://www.htmlcodetutorial.com/ 2. http://www.w3.org/MarkUp/ 3. http:www.w3schools.com/(classroom


study)

Das könnte Ihnen auch gefallen