PK-WT-Unit - 02 - HTML
PK-WT-Unit - 02 - HTML
Web Technologies
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
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 Elements
• An HTML element is everything from the start
tag to the end tag: Start tag * Element
content End tag *
• The start tag is often called the opening tag. The end tag is
often called the closing tag.
HTML Element Syntax
<!DOCTYPE html>
<html>
<body>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p> This is a paragraph.
</body> This is a paragraph.
This is a paragraph.
</html>
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
HTML Link Syntax
<!DOCTYPE html>
<html>
<body>
<p>This is a paragraph.</p>
<a href="http://www.ruraluniv.ac.in">This is a link</a>
<p>This is another paragraph.</p>
</body>
</html>
HTML Links - The target Attribute
• The target attribute specifies where to open
the linked document.
• The example below will open the linked
document in a new browser window:
Example
<a href=http://www.ruraluniv.ac.in
target="_blank “>Visit GRI</a>
HTML Links - The name Attribute
• The name attribute specifies the name of an
anchor.
<h3><a name="a003">a003</a></h3>
<h3><a name="menu">Menu</a></h3> <p>paragraph text fghfghfgjf
<ul> wrwerwtet
<li><a href="#a001">Jump to a001</a></li> fghfgjfjgk
<li><a href="#a002">Jump to a002</a></li> tryrtutyitit
fhgjgjg
<li><a href="#a003">Jump to a003</a></li>
yytiyioy
</ul> ghghkhkg
gjgkghk ...</p>
<h3><a name="a001">a001</a></h3>
<p>paragraph text ssssssssssssssssssss <hr>
ssssssssssssssssssssssssssssssssssssss <p><a href="#menu">Jump to Menu</a></p>
ssssssssssssssssssssssssssssssssssssss
</body>
ssssssssssssssssssssssssssssssssssssss </html>
ssssssssssssssssssssssssssssssssssssss
ssssssssssssssssssssssss ...</p>
HTML the <img> Tag and the src Attribute
<p>An image
<img src="smiley.gif" alt="Smiley face" align="bottom" width="32" height="32" />
with align="bottom".</p>
<p>An image
<img src="smiley.gif" alt="Smiley face" align="middle" width="32" height="32" />
with align="middle".</p>
<p>An image
<img src="smiley.gif" alt="Smiley face" align="top" width="32" height="32" />
with align="top".</p>
</body>
</html>
HTML Special Characters
• Many mathematical, technical, and currency
symbols, are not present on a normal
keyboard.
• To add these symbols to an HTML page, we
can use an HTML entity name.
• If no entity name exists, we can use an entity
number; a decimal (or hexadecimal)
reference.
• Example
<p>I will display €</p>
<p>I will display €</p>
<p>I will display €</p>
• Output
I will display €
I will display €
I will display €
HTML Horizontal Rule
• The <hr> tag defines a thematic break in an HTML
page (e.g. a shift of topic).
• The <hr> element is used to separate content (or
define a change) in an HTML page.
<h1>HTML</h1>
<p>HTML is a language for describing web pages.....</p>
<hr>
<h1>CSS</h1>
<p>CSS defines how to display HTML elements.....</p>
HTML Lists
• Ordered List
• Unordered List
• Description/Definition Lists
• Nested List
• Horizontal List
HTML Unordered Lists
• An unordered list starts with the <ul> tag.
Each list item starts with the <li> tag.
• The list items are marked with bullets
(typically small black circles).
<html>
<body>
<h4>Disc bullets list:</h4>
<ul type="disc">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
</ul>
<h2>HTML Forms</h2>
<form action="/action_page.php">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
<input type="submit" value="Submit">
</form>
<p>If you click the "Submit" button, the form-data will be sent to a page called
"/action_page.php".</p>
</body>
</html>
The <input> Element
<html>
<body>
<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>
</body>
</html>
Group together related options with <optgroup> tags:
The <optgroup> tag is used to group together related options in a select
list.
If you have a long list of options, groups of related options are easier to
handle for the user.
<select>
<optgroup label="Swedish Cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
</optgroup>
<optgroup label="German Cars">
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</optgroup>
</select>
• To create a button
<html>
<body>
<form action="">
<input type="button" value="Hello world!">
</form>
</body>
</html>
Fieldset tag
• Definition and Usage
• The <fieldset> tag is used to logically group together elements in a form.
• The <fieldset> tag draws a box around the related form elements.
• The <legend> tag defines a caption for the fieldset element
HTML Frames
• HTML Frames
• 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 HTML frameset Element
• The frameset element holds two or more
frame elements. Each frame element holds a
separate document.
• The frameset element states only HOW MANY
columns or rows there will be in the frameset.
• The HTML frame Element
• The <frame> tag defines one particular window (frame)
within a frameset.
• In the example below we have a frameset with two
columns.
• The first column is set to 25% of the width of the browser
window. The second column is set to 75% of the width of
the browser window. The document "frame_a.htm" is
put into the first column, and the document
"frame_b.htm" is put into the second column:
<frameset cols="25%,75%">
<frame src="frame_a.htm" />
<frame src="frame_b.htm" />
</frameset>
Note: The frameset column size can also be set in pixels (cols="200,500"), and one of the
columns can be set to use the remaining space, with an asterisk (cols="25%,*").
<html>
<frameset rows="50%,50%">
<frame src="frame_a.htm" />
<frameset cols="25%,75%">
<frame src="frame_b.htm" />
<frame src="frame_c.htm" />
</frameset>
</frameset>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Example of HTML Frames using row
attribute</title>
</head>