Lab01 - HTML
Lab01 - HTML
1. Introduction to HTML
Website Design and Development
A. OVERVIEW
1. Learning Objective
In this lab, students will learn how to create web pages using HTML, including:
2
Figure 1: Visual Code Studio
B. LAB TASKS
1. The first web page
a. Organize a webpage
▪ First, we create a new directory for hosting all website resources, such as
source code, images, fonts, etc. Create a new directory and its sub-directories
as below:
Lab 1/
├─ index.html file
├─ images/ directory
├─ styles/ directory
├─ scripts/ directory
o The file index.html is the main HTML document for your web page. You
can open this file with a Browser Application (e.g., Firefox, Chrome) to view
your designed website directly.
o images: This directory will contain all the images you use on your site.
o styles: This directory will have the Cascading Style Sheets (CSS) code used
to style your content (for example, setting text and background colors).
o scripts: This directory will contain all the JavaScript code used to add
interactive functionality to your site (e.g., buttons that load data when
clicked).
b. Open this directory with Visual Studio Code (VSCode)
3
▪ Browse to the created directory above.
c. Create a "Hello World" site
▪ Open the file index.html with Browser Application, such as Safari, MS Edge,
Chrome, etc, and view your site.
2. HTML Basic
a. HTML headings
HTML headings are defined with the <h1> to <h6> tags. <h1> defines the most
important heading. <h6> defines the least important heading.
4
Example:
<h1>This is heading 1</h1> This is heading 1
<h2>This is heading 2</h2> This is heading 2
<h3>This is heading 3</h3> This is heading 3
Search engines use the headings to index the structure and content of your web
pages. Users often skim a page by its headings. It is important to use headings to
show the document structure. <h1> headings should be used for main headings,
followed by <h2> headings, then the less important <h3>, and so on. Use HTML
headings for headings only. Don't use headings to make text BIG or bold.
b. HTML paragraphs
The HTML <p> element defines a paragraph. A paragraph always starts on a new
line, and browsers automatically add some white space (a margin) before and after
a paragraph.
Example:
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
c. HTML links
HTML links are hyperlinks. You can click on a link and jump to another
document. When you move the mouse over a link, the mouse arrow will turn into
a little hand.
The HTML <a> tag defines a hyperlink. It has the following syntax:
The most important attribute of the <a> element is the href attribute, which
indicates the destination link. The link text is the part that will be visible to the
reader.
The target attribute: By default, the linked page will be displayed in the current
browser window. To change this, you must specify another target for the link. The
target attribute specifies where to open the linked document. The target attribute
can have one of the values:
▪ _self: Default. Opens the document in the same window/tab as it was clicked.
5
▪ _parent: Opens the document in the parent frame.
d. HTML images
Images can improve the design and the appearance of a web page. The HTML
<img> tag is used to embed an image in a web page. Images are not technically
inserted into a web page; images are linked to web pages . The <img> tag creates a
holding space for the referenced image. The <img> tag is empty, it contains
attributes only and does not have a closing tag. Two required attributes of <img>
tag are src (specifies the path to the image) and alt (specifies an alternate text for
the image)
Example:
<img src="https://www.uit.edu.vn/sites/vi/files/images/Logos/Logo_UIT_Web.png" alt="UIT">
e. Exercise
Design your site to introduce a book. You need to use the introduced tags in this
section to get the result as below:
3. HTML Elements
In this task, you will learn more complex HTML tags. Let's search for the purpose
and how to use these tags:
▪ div: https://www.w3schools.com/tags/tag_div.ASP
▪ span: https://www.w3schools.com/tags/tag_span.asp
▪ list: https://www.w3schools.com/html/html_lists.asp
▪ table: https://www.w3schools.com/html/html_tables.asp
6
Exercise: improve your site in the task 2
4. HTML Tags
Attributes provide additional information about elements. Attributes are always
specified in the start tag. Attributes usually come in name/value pairs like
name="value". Especially, All HTML elements can have attributes.
▪ width and height: used to set the width and height of the image ( <img>).
▪ Style: add styles to an element, such as color, font, size, and more.
▪ Lang: should always include lang attribute inside html tag, to declare the
language of the Web page. Country codes can also be added to the language
code in the lang attribute. So, the first two characters define the language
of the HTML page, and the last two characters define the country.
<!DOCTYPE html>
<html lang="en-US">
<body>
...
</body>
</html>
▪ Title: defines some extra information about an element. The value of the
title attribute will be displayed as a tooltip when you mouse over the
element.
7
<p title="I'm a tooltip">This is a paragraph.</p>
5. Exercise
Improve your site from the tasks above to get the results as below:
8
C. REQUIREMENTS AND SUBMISSION
You are expected to complete all tasks in section B (Lab tasks). Advanced tasks
are optional, and you could get bonus points for completing those tasks. This lab
is designed for individuals. You have 7 days to clear all tasks.
▪ If the submission contains more than 1 file, you need to place everything
inside a folder where its name pattern is "LabX-StudentID-Name". Then,
archive this folder under the zip format.
Your submissions must be your own. You are free to discuss with other classmates
to find the solution. However, copying is prohibited, even if only a part of your
report. Both reports of the owner and the copier will be rejected. Please remember
to cite any source of the material (website, book,…) that influences your solution.
D. REFERENCES
1. W3Scholl HTML Tutorial: https://www.w3schools.com/html/
2. HTML elements references: https://developer.mozilla.org/en-US/docs/Web/HTML/Element
3. HTML Tutorial: https://www.geeksforgeeks.org/html