Professional Documents
Culture Documents
Technologies
Lecture 4: HTML Elements
Dr. Lupiana, D
FCIM, Institute of Finance Management
Semester 2
Agenda:
• Intro to HTML
• HTML elements
1
Basic Web Development Tools
• A Web Server
– This is required if you are dealing with server-side
scripting languages such as PHP, ASP and Ruby
HTML Basics
• A web page is created through an HTML
document
• HTML document is a text file saved with .html
or .htm file extension
HTML Basics
• An HTML document consists of two sections;
HEAD section and BODY section
<html>
<head>
</head>
<body>
</body>
</html>
6
2
HTML Basics
• The Head section provides information about
an HTML document
– It can be used to specify a title of a Web page,
style, links to other pages such JavaScript and CSS
• In the Body section is where content of a web page
is presented and organized
– It is the visible content of an HTML page
– Through the body, a web developer creates a web
page as represented by the page’s mockup
HTML Basics
• HTML document is written by HTML – Hyper
Text Markup Language
• HTML – Hyper Text Markup Language
– It is a clear text and case insensitive language
– It ignores any white space
HTML Basics
• HTML tags generally ‘open’ and ‘close’ – except for
single-element tags like <img>, <br> and <hr>.
3
HTML Basics
• Comments are enclosed in <!-- and -->
• Example
<!--This comment will not be displayed-->
<p>This is a regular paragraph</p>
10
10
HTML Elements
• HTML documents are made up of HTML
elements.
• HTML elements are made by a combination of
a start tag, end tag and content in between.
<tag name> content </tag name>
11
11
HTML Element
• The HTML element is everything from the
start HTML tag to the end HTML tag.
• HTML elements with no contents (i.e. have no
closing tag) are called empty HTML elements.
• Examples of empty HTML elements;
– <img> (for defining images)
– <br> (for inserting line break)
– <hr> (for defining an horizontal rule/line)
12
12
4
HTML Element
• Every HTML element has a default display
value, depending on what type of element it is.
• The default display value for most elements is
block or inline.
• Consequently, elements are categorized as;
– Block-level elements
– Inline elements
13
13
14
14
15
15
5
HTML Elements: Block-level elements
• Block-level elements may contain inline
elements and other block-level elements.
16
16
17
17
18
18
6
:: Rules for Nesting HTML elements
19
20
20
21
21
7
HTML Elements: Attributes
• Attributes are always specified in the start tag
(in between “<” and “>” signs of the tag) and
come in name and value pairs.
• Name is the name of a property you want to
set whereas value is what you want the
attribute to be set.
• Values are written after the “=“ sign after the
name of the attribute.
22
22
23
23
24
24
8
HTML Elements: Attributes: Style
• For example, the style attribute of the division
<div> element can be defined as follow;
property value
25
25
26
26
27
27
9
HTML Elements: Attributes: Class
• Unlike other attributes, the class attribute
must be defined by a developer before it can
be used.
• The class attribute is defined with the <style>
element in the <head> element of an HTML
document.
28
28
29
29
30
30
10
HTML Elements: Attributes: Class
• After you have defined the class, you can use
the class to change the style of relevant HTML
elements.
• To use the defined class, when defining a
relevant HTML element, you simply assign it
as a value of a class attribute.
31
31
32
32
33
33
11
HTML Elements: Attributes
• Although single quotes can also be used, it is
common in HTML for a value of an attribute to
be specified in double quotes.
• It is necessary, however, to use single quotes
when the attribute value itself contains
double quotes.
34
34
12