Lab 02ggttt
Lab 02ggttt
MANUAL
Activity Outcomes:
This lab teaches you the following:
Writing First Program in HTML, Running the HTML Code
Introduce HTML tag with their properties
How to design HTML page using different HTML elements (<h1>…<h6>, <a>, <p>,
<img>, <ol> etc)
How to create tables in HTML
How to display values in block and inline
Figure: Snapshot showing the window where you can write the HTML code.
The figure below shows the HTML code that we wrote for our first lab exercise. The HTML
code is divided into two main parts: (a) <head> and (b) <body>. We learned in-detail in the
theory lecture.
Once you saved the file, go to the location where you have saved the ‘html’ file.
Double click on the ‘my-first.html’ to open the file in default web browser to see the
output, shown in the figure below.
The href Attribute HTML links are defined with the <a> tag. The link address is specified
in the href attribute: Example 1
Example 2
In this example, we use the <img> with its three attributes: (a) src=”used to
provide the location of the image”, (b) width= “for width of the image in pixel”, (c)
height= “for height of the image in pixel” and (d) alt=”The alt attribute specifies an
alternative text to be used, if an image cannot be displayed.
Following is the html code to display the image with a link displaying ‘Buy’
In this activity, we will learn about different headings. Headings are defined with
the <h1> to <h6> tags. <h1> defines the most important heading. <h6> defines the least
important heading. To understand its working, the following code is helpful
Figure: Code for Heading tag <h>
Item1
Item2
Item3
Item4
An Ordered List:
1. First item
2. Second item
3. Third item
4. Fourth item
To implement the table in HTML, please recall the theory which we studied
in the theory class of this course. Using the already developed knowledge, we will
implement the concept of table in HTML. The following HTML code generates the
table showed above.
<!DOCTYPE html>
<html>
<head>
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}
</style>
</head>
<body>
<h2>HTML Table</h2>
<table>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
</tr>
<tr>
<td>Centro comercial Moctezuma</td>
<td>Francisco Chang</td>
<td>Mexico</td>
</tr>
<tr>
<td>Ernst Handel</td>
<td>Roland Mendel</td>
<td>Austria</td>
</tr>
<tr>
<td>Island Trading</td>
<td>Helen Bennett</td>
<td>UK</td>
</tr>
<tr>
<td>Laughing Bacchus Winecellars</td>
<td>Yoshi Tannamuri</td>
<td>Canada</td>
</tr>
<tr>
<td>Magazzini Alimentari Riuniti</td>
<td>Giovanni Rovelli</td>
<td>Italy</td>
</tr>
</table>
</body>
</html>
Lab Task 1:
Create the following table using table element
Activity-5
Block-level Elements
A block-level element always starts on a new line and takes up the full width
available (stretches out to the left and right as far as it can).
<address> <article> <canvas> <dd> <div> <dl> <dt> <fieldset> <figcaption> <figure>
<footer> <form> <h1>-<h6> <header> <hr> <li> <main> <nav> <noscript> <ol> <p> <pre>
<section> <table> <tfoot> <ul> <video>
Inline Elements
An inline element does not start on a new line and only takes up as much width as
necessary.
<a> <abbr> <acronym> <b> <bdo> <big> <br> <button> <cite> <code> <dfn> <em> <i> <img>
<input> <kbd> <label> <map> <object> <output> <q> <samp> <script> <select> <small>
<span> <strong> <sub> <sup> <textarea> <time> <tt> <var>
Activity-6
HTML Formatting Elements
HTML uses elements like <b> and <i> for formatting output, like bold or italic text.