Web System and Technologies II - HTML Basic
Web System and Technologies II - HTML Basic
HTML Basic
1.0 Learning Outcomes
Able to define the basics of HTML, particularly the Elements and Attributes.
1.1 Introduction
In this Module we will show some basic HTML examples. Don't worry if we use tags
you have not learned about yet.
1.2 Topics/Discussion
1.2.1 HTML Document
All HTML documents must start with a document type declaration: <!DOCTYPE html>.
The <!DOCTYPE> declaration represents the document type, and helps browsers to display web
pages correctly.
It must only appear once, at the top of the page (before any HTML tags).
The source file (src), alternative text (alt), width, and height are provided as attributes:
An HTML element is defined by a start tag, some content, and an end tag.
HTML elements can be nested (this means that elements can contain other elements).
Example:
Example Explained
The <html> element is the root element and it defines the whole HTML document.
The <b ody> ele
ment defines the document's body.
Some HTML elements will display correctly, even if you forget the end tag:
However, never rely on this! Unexpected results and errors may occur if you forget
the end tag!
The <br> tag defines a line break, and is an empty element without a closing tag:
6
LEARNING PACKET 3 | Web System and Technologies II
HTML Basic Learning Packet 1
The HTML standard does not require lowercase tags, but W3C recommends lowercase
in HTML, and demands lowercase for stricter document types like XHTML.
The <a> tag defines a hyperlink. The href attribute specifies the URL of the page the
link goes to:
7
LEARNING PACKET 3 | Web System and Technologies II
HTML Basic Learning Packet 1
Notes: External images might be under copyright. If you do not get permission to use it,
you may be in violation of copyright laws. In addition, you cannot control external
images; it can suddenly be removed or changed.
2. Relative URL - Links to an image that is hosted within the website. Here, the URL
does not include the domain name. If the URL begins without a slash, it will be relative
to the current page. Example: src="img_girl.jpg". If the URL begins with a slash, it will
be relative to the domain. Example: src="/images/img_girl.jpg".
Tip: It is almost always best to use relative URLs. They will not break if you change
domain.
The required alt attribute for the <img> tag specifies an alternate text for an image, if the
image for some reason cannot be displayed. This can be due to slow connection, or an
error in the src attribute, or if the user uses a screen reader.
See what happens if we try to display an image that does not exist:
The style attribute is used to add styles to an element, such as color, font, size, and more.
9
LEARNING PACKET 3 | Web System and Technologies II
HTML Basic Learning Packet 1
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.
The value of the title attribute will be displayed as a tooltip when you mouse over the
element:
10
LEARNING PACKET 3 | Web System and Technologies II
HTML Basic Learning Packet 1
1.3 References
https://www.w3schools.com/
1.4 Acknowledgment
The images, tables, figures and information contained in this module were
taken from the references cited above.