Presentation is loading. Please wait.

Presentation is loading. Please wait.

Farhan Nisar University of Peshawar

Similar presentations


Presentation on theme: "Farhan Nisar University of Peshawar"— Presentation transcript:

1 Farhan Nisar University of Peshawar
Introduction to Html Farhan Nisar University of Peshawar

2 HTML Introduction 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

3 HTML Tags HTML markup tags are usually called HTML tags
HTML tags are keywords surrounded by angle brackets like <html> HTML tags normally come in pairs like <b> and </b> The first tag in a pair is the start tag, the second tag is the end tag Start and end tags are also called opening tags and closing tags

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

5 HTML Headings <h1>This is a heading</h1> <h2>This is a heading</h2> <h3>This is a heading</h3> HTML Paragraphs <p>This is a paragraph.</p> <p>This is another paragraph.</p>

6 HTML Links <a href=" is a link</a> HTML Images <img src=“ALONE.jpg" width="104" height="142" />

7 HTML Attributes HTML elements can have attributes
Attributes provide additional information about an element Attributes are always specified in the start tag Attributes come in name/value pairs like: name="value“ <a href=" is a link</a>

8 HTML Lines The <hr /> tag creates a horizontal line in an HTML page. <p>This is a paragraph</p> <hr /> <p>This is a paragraph</p> <hr /> <p>This is a paragraph</p>

9 HTML Comments Comments can be inserted into the HTML code to make it more readable and understandable. Comments are ignored by the browser and are not displayed. <!-- This is a comment -->

10 HTML Line Breaks Use the <br /> tag if you want a line break (a new line) without starting a new paragraph: <p>This is<br />a para<br />graph with line breaks</p>

11 HTML Formatting Tags HTML uses tags like <b> and <i> for formatting output, like bold or italic text. These HTML tags are called formatting tags (look at the bottom of this page for a complete reference). <i> Defines italic text <strong> Defines strong text

12 The HTML <font> Tag
<font> tag is deprecated in HTML 4, and removed from HTML5. The World Wide Web Consortium (W3C) has removed the <font> tag from its recommendations. In HTML 4, style sheets (CSS) should be used to define the layout and display properties for many HTML elements.  The example below shows how the HTML could look by using the <font> tag:

13 Example <p> <font size="5" face="arial" color="red"> This paragraph is in Arial, size 5, and in red text color. </font> </p> <p> <font size="3" face="verdana" color="blue"> This paragraph is in Arial, size 5, and in red text color. </font> </p>

14 Styling HTML with CSS CSS was introduced together with HTML 4, to provide a better way to style HTML elements. CSS can be added to HTML in the following ways: in separate style sheet files (CSS files) in the style element in the HTML head section in the style attribute in single HTML element

15 HTML Style Example - Background Color
<html> <body style="background-color:yellow;"> <h2 style="background-color:red;">This is a heading</h2> <p style="background-color:green;">This is a paragraph.</p> </body> </html>

16 HTML Style Example - Font, Color and Size
<html> <body> <h1 style="font-family:verdana;">A heading</h1> <p style="font-family:arial;color:red;font-size:20px;">A paragraph.</p> </body> </html>

17 HTML Style Example - Text Alignment
<html> <body> <h1 style="text-align:center;">Center-aligned heading</h1> <p>This is a paragraph.</p> </body> </html>

18 HTML Hyperlinks (Links)
A hyperlink (or link) is a word, group of words, or image that you can click on to jump to a new document or a new section within the current document. When you move the cursor over a link in a Web page, the arrow will turn into a little hand. Links are specified in HTML using the <a> tag. The <a> tag can be used in two ways: To create a link to another document, by using the href attribute To create a bookmark inside a document, by using the name attribute Syntex <a href="url">Link text</a>

19 Example <a href="http://www.Farhan.com/">Visit farhan</a>
HTML Links - The target Attribute <a href=" target="_blank">Visit farhan!</a>

20 HTML Images -  The <img> tag is empty, which means that it contains attributes only, and has no closing tag. To display an image on a page, you need to use the src attribute. Src stands for "source". The value of the src attribute is the URL of the image you want to display . <img src="url" alt="some_text"/> <img src=“rock.jpg" alt=" rock" width="304" height="228" />

21 HTML 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). td stands for "table data," and holds the content of a data cell. A <td> tag can contain text, links, images, lists, forms, other tables, etc

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

23 HTML Table Headers <table border="1"> <tr> <th>Header 1</th> <th>Header 2</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 2</td> </tr> </table>

24 HTML Lists Unordered Lists
An unordered list starts with the <ul> tag. Each list item starts with the <li> tag. <ul> <li>Coffee</li> <li>Milk</li> </ul>

25 HTML Ordered Lists An ordered list starts with the <ol> tag. Each list item starts with the <li> tag. <ol> <li>Coffee</li> <li>Milk</li> </ol>

26 HTML Definition Lists A definition list is a list of items, with a description of each item. The <dl> tag defines a definition list. The <dl> tag is used in conjunction with <dt> (defines the item in the list) and <dd> (describes the item in the list): <dl> <dt>Coffee</dt> <dd>- black hot drink</dd> <dt>Milk</dt> <dd>- white cold drink</dd> </dl>

27 HTML Forms HTML forms are used to pass data to a server.
A form can contain input elements like text fields, checkboxes, radio-buttons, submit buttons and more. A form can also contain select lists, textarea, fieldset, legend, and label elements. The <form> tag is used to create an HTML form: <form> . input elements . </form>

28 Text Fields <form> First name: <input type="text" name="firstname" /><br /> Last name: <input type="text" name="lastname" /> Password: <input type="password" name="pwd" /> </form>

29 Radio Buttons <form> <input type="radio" name="sex" value="male" /> Male<br /> <input type="radio" name="sex" value="female" /> Female </form>

30 Checkboxes <form> <input type="checkbox" name="vehicle" value="Bike" /> I have a bike<br /> <input type="checkbox" name="vehicle" value="Car" /> I have a car  </form>

31 Submit Button <form name="input" action="html_form_action.asp" method="get"> Username: <input type="text" name="user" /> <input type="submit" value="Submit" /> </form>

32 The HTML frameset Element
The frameset element holds one or more frame elements. Each frame element can hold a separate document. The frameset element states HOW MANY columns or rows there will be in the frameset, and HOW MUCH percentage/pixels of space will occupy each of them.

33 The HTML frame Element <frameset cols="25%,75%">    <frame src="frame_a.htm" />    <frame src="frame_b.htm" /> </frameset> Note: <frameset>Defines a set of frames <frame />Defines a sub window (a frame) <iframe>Defines an inline sub window (frame)

34 HTML Iframes An iframe is used to display a web page within a web page. <iframe src="URL"></iframe>

35 Use iframe as a Target for a Link
An iframe can be used as the target frame for a link <iframe src="demo_iframe.htm" name="iframe_a"></iframe> <p><a href=" target="iframe_a">alonee.com</a></p>

36 HTML Colors HTML colors are defined using a hexadecimal notation (HEX) 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 (in HEX: 00). The highest value is 255 (in HEX: FF)

37 Entities < is the same as < > is the same as > © is the same as © <div>Defines a section in a document <style>Defines style information for a document <link />Defines the relationship between a document and an external resource

38 Blockquote <!-- This is a comment -->
<blockquote> Text quoted from a source. </blockquote> <address> Written by farhan.com<br /> <a us</a><br /> Address: Box 564, Disneyland<br /> Phone: </address>

39 HTML Layouts - Using Tables
<html> <body> <table width="500" border="0"> <tr> <td colspan="2" style="background-color:#FFA500;"> <h1>Main Title of Web Page</h1> </td> </tr> <tr valign="top"> <td style="background-color:#FFD700;width:100px;text-align:top;"> <b>Menu</b><br /> HTML<br /> CSS<br /> JavaScript </td> <td style="background-color:#EEEEEE;height:200px;width:400px;text-align:top;"> Content goes here</td> </tr> </table> </body> </html>

40 HTML Doctypes A doctype declaration refers to the rules for the markup language, so that the browsers render the content correctly <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " <html> <head> <title>Title of the document</title> </head> <body> The content of the document </body> </html>

41 External Style Sheet An external style sheet is ideal when the style is applied to many pages. With an external style sheet, you can change the look of an entire Web site by changing one file. Each page must link to the style sheet using the <link> tag. The <link> tag goes inside the <head> section: <head> <link rel="stylesheet" type="text/css" href="mystyle.css" /> </head>

42 Internal Style Sheet An internal style sheet can be used if one single document has a unique style. Internal styles are defined in the <head> section of an HTML page, by using the <style> tag, like this: <head> <style type="text/css"> body {background-color:yellow;} p {color:blue;} </style> </head>

43 Inline Style An inline style can be used if a unique style is to be applied to one single occurrence of an element. To use inline styles, use the style attribute in the relevant tag. The style attribute can contain any CSS property. The example below shows how to change the text color and the left margin of a paragraph: <p style="color:blue;margin-left:20px;">This is a paragraph.</p>

44 The HTML title Element <html> <head> <title>Title of the document</title> </head> <body> The content of the document </body> </html>

45 The HTML base Element <head> <base href=" /> <base target="_blank" /> </head>

46 The HTML script Element
<script type="text/javascript"> document.write("Hello World!") </script>

47 The HTML noscript Element
<script type="text/javascript"> document.write("Hello World!") </script> <noscript>Sorry, your browser does not support JavaScript!</noscript>

48 ADD a video <html> <body> <embed src=“farhan.mp4”>

49 URL - Uniform Resource Locator
When you click on a link in an HTML page, an underlying <a> tag points to an address on the world wide web. A Uniform Resource Locator (URL) is used to address a document (or other data) on the world wide web. scheme://host.domain:port/path/filename scheme - defines the type of Internet service. The most common type is http host - defines the domain host (the default host for http is www) domain - defines the Internet domain name, like w3schools.com :port - defines the port number at the host (the default port number for http is 80)  path - defines a path at the server (If omitted, the document must be stored at the root directory of the web site) filename - defines the name of a document/resource

50 The Easiest Way to Add Audio to Your Site
<a href="song.mp3">Play Song</a> <script type="text/javascript" src=" </script>

51 Playing Audio in HTML <audio controls="controls" height="50px" width="100px">   <source src="song.mp3" type="audio/mpeg" />   <source src="song.ogg" type="audio/ogg" /> <embed height="50px" width="100px" src="song.mp3" /> </audio>

52 Using the Yahoo Media Player
<a href="song.mp3">Play Song</a> <script type="text/javascript" src="

53 Using A Hyperlink If a web page includes a hyperlink to a media file, most browsers will use a "helper application" to play the file. <a href="song.mp3">Play the song</a>

54 Playing Videos in HTML <!DOCTYPE HTML> <html> <body>
<video width="320" height="240" controls="controls"> <source src="movie.ogg" type="video/ogg" /> <source src="movie.mp4" type="video/mp4" />   <source src="movie.webm" type="video/webm" /> <object width="320" height="240" src="movie.mp4"> <embed width="320" height="240" src="movie.swf"> Your browser does not support video </embed> </object> </video> </body> </html>

55 Video in Full screen If a web page includes a hyperlink to a media file, most browsers will use a "helper application" to play the file. <a href="intro.swf">Play a video file</a>

56 Playing a YouTube Video in HTML
<iframe width="420" height="345" src=" </iframe>

57 FANKS Special thanks to Raza who helped me


Download ppt "Farhan Nisar University of Peshawar"

Similar presentations


Ads by Google