Beruflich Dokumente
Kultur Dokumente
Unit -10
Introduction to HTML
It stands for Hyper Text Markup Language.
It is markup language used to create HTML documents (web pages) on
internet.
A markup language is a set of markup tags. HTML documents are described
by HTML tags Each HTML tag describes different document content of web
page.
It is interpreted by the web browser. The web browser is the software that
runs on computer and interprets the HTML tags to display the content of the
Web page.
It was developed by Berners Lee in 1990 at CERN.
Examples of markup language: DHTML, SGML, XHTML, XML etc.
Uses of HTML
</html>
Line Break Tag
Whenever you use the <br /> element, anything following it starts from the next
line. This tag is an example of an empty element, where you do not need opening
and closing tags, as there is nothing to go in between them.
<html>
<head>
<title>Line Break Example</title>
</head>
<body>
<p>Hello<br />
You delivered your assignment on time.<br />
Thanks<br />
Mahnaz</p>
</body>
Prepared By Niraj Shrestha
</html>
Centering Content
You can use <center> tag to put any content in the center of
the page or any table cell.
<html>
<head>
<title> Centering Content Example</title>
</head>
<body>
<p>This text is not in the center.</p>
<center> <p>This text is in the center.</p> </center>
</body>
</html>
Prepared By Niraj Shrestha
Horizontal Lines
Horizontal lines are used to visually break up sections of a document.
The <hr> tag creates a line from the current position in the document
to the right margin and breaks the line accordingly.
<html>
<head>
<title>Horizontal Line Example</title>
</head>
<body>
<p>This is paragraph one and should be on top</p> <hr/>
<p>This is paragraph two and should be at bottom</p>
</body>
</html>
Prepared By Niraj Shrestha
HTML Formatting Elements
In the previous chapter, you learned about HTML styling, using the HTML style attribute.
HTML also defines special elements, for defining text with a special meaning.
HTML uses elements like <b> and <i> for formatting output, like bold or italic text.
Formatting elements were designed to display special types of text:
•Bold text
•Important text
•Italic text
•Emphasized text
•Marked text
•Small text
•Deleted text
•Inserted text
•Subscripts
•Superscripts
</body>
</html>
Prepared By Niraj Shrestha
HTML Subscript Formatting HTML Superscript
Formatting
The HTML <sub> element defines The HTML <sup> element defines
subscripted text. superscripted text.
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<body> <body>
<p>This is <sub>subscripted</sub> <p>This is
text.</p> <sup>superscripted</sup> text.</p>
</body> </body>
</html> </html>
•The name is the property you want to set. For example, the paragraph <p>
element in the example carries an attribute whose name is align, which you can use
to indicate the alignment of paragraph on the page.
•The value is what you want the value of the property to be set and always put
within quotations. The below example shows three possible values of align
attribute: left, center and right
<!DOCTYPE html>
<html>
<body style="background-color:lightgrey;">
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Prepared By Niraj Shrestha
HTML Text Color
The color property defines the text color for an HTML
element:
<!DOCTYPE html>
<html>
<body>
<h1 style="color:blue;">This is a heading</h1>
<p style="color:red;">This is a paragraph.</p>
</body>
</html>
Prepared By Niraj Shrestha
HTML Fonts
The font-family property defines the font to be used for an
HTML element:
<!DOCTYPE html>
<html>
<body>
<h1 style="font-family:verdana;">This is a heading</h1>
<p style="font-family:courier;">This is a paragraph.</p>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h1 style="font-size:300%;">This is a heading</h1>
<p style="font-size:160%;">This is a paragraph.</p>
</body>
</html>
Prepared By Niraj Shrestha
HTML Text Alignment
The text-align property defines the horizontal text
alignment for an HTML element
<!DOCTYPE html>
<html>
<body>
<h1 style="text-align:center;">Centered heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
NOTE Always specify the width and height of an image. If width and height are not
specified,
Prepared the page will flicker while the image loads.
By Niraj Shrestha
HTML Lists
<!DOCTYPE html>
<html>
<body>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
</body>
Prepared By Niraj Shrestha
</html>
Unordered HTML Lists - The Style Attribute
A style attribute can be added to an unordered list, to define the style of the marker:
Style Description
list-style-type:disc The list items will be marked with bullets (default)
<ul style="list-style-type:disc">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
</body>
Prepared By Niraj Shrestha
</html>
Circle:
<!DOCTYPE html>
<html>
<body>
<ul style="list-style-type:circle">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
Prepared By Niraj Shrestha
</body>
Square:
<!DOCTYPE html>
<html>
<body>
<ul style="list-style-type:square">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
Prepared By Niraj Shrestha
</body>
</html>
None:
<!DOCTYPE html>
<html>
<body>
<ul style="list-style-type:none">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
</body>
Prepared By Niraj Shrestha
</html>
Ordered HTML Lists
An ordered list starts with the <ol> tag. Each list item starts with
the <li> tag.
The list items will be marked with numbers:
<!DOCTYPE html>
<html>
<body>
<h2>Ordered List</h2>
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
</body>
Prepared By Niraj Shrestha </html>
Ordered HTML Lists - The Type Attribute
A type attribute can be added to an ordered list, to define the type of the
marker:
Type Description
type="1" The list items will be numbered with numbers (default)
type="A" The list items will be numbered with uppercase letters
type="a" The list items will be numbered with lowercase letters
type="I" The list items will be numbered with uppercase roman numbers
type="i" The list items will be numbered with lowercase roman numbers
<!DOCTYPE html>
<html>
<body>
<ol type="1">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
</body>
</html>
Prepared By Niraj Shrestha
Uppercase Letters:
<!DOCTYPE html>
<html>
<body>
<ol type="A">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
</body>
</html>
Prepared By Niraj Shrestha
Lowercase Letters:
<!DOCTYPE html>
<html>
<body>
<ol type="a">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
</body>
Prepared By Niraj Shrestha
</html>
Uppercase Roman Numbers:
<!DOCTYPE html>
<html>
<body>
<ol type="I">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
</body>
</html>
Prepared By Niraj Shrestha
Lowercase Roman Numbers:
<!DOCTYPE html>
<html>
<body>
<ol type="i">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
</body>
Prepared By Niraj Shrestha
</html>
HTML Description Lists
HTML also supports description lists.
A description list is a list of terms, with a description of each term.
The <dl> tag defines the description list, the <dt> tag defines the term (name), and the <dd> tag
describes each term:
<!DOCTYPE html>
<html>
<body>
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
</body>
Prepared By Niraj Shrestha
</html>
Nested HTML Lists
List can be nested (lists inside lists):
<!DOCTYPE html>
<html>
<body>
<h2>A Nested List</h2>
<ul>
<li>Coffee</li>
<li>Tea
<ul>
<li>Black tea</li>
<li>Green tea</li>
</ul>
</li>
<li>Milk</li>
</ul>
</body>
Prepared By Niraj Shrestha
</html>
HTML Tables
HTML Table Example
Tables are divided into table rows with the <tr> tag.
Table rows are divided into table data with the <td> tag.
<td>Smith</td>
An HTML Table with Cell Padding
Cell padding specifies the space between the cell content and its borders.
If you do not specify a padding, the table cells will be displayed without padding.
To set the padding, use the CSS padding property:
<!DOCTYPE html> <body> <tr>
<html> <td>John</td>
<head> <table style="width:100%"> <td>Doe</td>
<style> <tr> <td>80</td>
table, th, td { <td>Jill</td> </tr>
border: 1px solid black; <td>Smith</td> </table>
border-collapse: <td>50</td>
collapse; </tr> </body>
} <tr> </html>
th, td { <td>Eve</td>
padding: 15px; <td>Jackson</td>
} <td>94</td>
</style> </tr>
</head>
Prepared By Niraj Shrestha
Prepared By Niraj Shrestha
HTML Table Headings
Table headings are defined with the <th> tag.
By default, all major browsers display table headings as bold and
centered:
}
<body>
<div id="header">
<h1>City Gallery</h1>
</div> <div id="footer">
<div id="nav"> Copyright HSMONLINE.EDU.NP
London<br> </div>
Paris<br>
Tokyo
</div> </body>
<div id="section"> </html>
<h2>London</h2>
<p>London is the capital city of England. It is the
most populous city in the United Kingdom,
with a metropolitan area of over 13 million
inhabitants.</p>
<p>Standing on the River Thames, London has been
a major settlement for two millennia,
its history going back to its founding by the
Romans, who named it Londinium.</p>
Prepared By Niraj Shrestha
</div>
The <form> Element
HTML forms are used to collect user input.
The <form> element defines an HTML form:
Type Description
text Defines normal text input
radio Defines radio button input (for selecting one of many choices)
submit Defines a submit button (for submitting the form)
<form>SEX:
<input type="radio" name="sex"
value="male" checked> Male
<input type="radio" name="sex"
value="female"> Female
</form>
</body>
</html>
Prepared By Niraj Shrestha
The Submit Button
<input type="submit"> defines a button for submitting a form to a form-handler.
The form-handler is typically a server page with a script for processing input data.
The form-handler is specified in the form's action attribute:
<!DOCTYPE html>
<br><br>
<html>
<input type="submit" value="Submit">
<body>
</form>
<form action="action_page.php">
<p>If you click the "Submit" button, the
First name:<br>
form-data will be sent to a page called
<input type="text" name="firstname"
"action_page.php".</p>
value="Mickey">
<br>
</body>
Last name:<br>
</html>
<input type="text" name="lastname"
value="Mouse">
Prepared By Niraj Shrestha
The <select> Element (Drop-Down List)
The <select> element defines a drop-down list:
</html>
The <textarea> Element
The <textarea> element defines a multi-line input field (a text area):
<!DOCTYPE html>
<html>
<body>
<form action="action_page.php">
<textarea name="message" rows="10"
cols="30">
Write your text here....
</textarea>
<br><br>
<input type="submit">
</form>
</body>
</html>
Prepared By Niraj Shrestha
Input Type Password
<form>
User name:<br>
<input type="text" name="username"><br>
User password:<br>
<input type="password" name="psw">
</form>
<form action="/action_page.php">
<input type="checkbox" name="vehicle" value="Bike"> I have a
bike<br>
<input type="checkbox" name="vehicle" value="Car" checked> I
have a car<br>
<input type="submit" value="Submit">
</form>