Introduction to HTML
Introduction to HTML
n TO
HTML
Learning
Objectives
Explain the fundamental structure of an
HTML document, including, elements, tags,
and attributes
Learning
Objectives
Explain the fundamental structure of an
HTML document, including, elements, tags,
and attributes
Write the a basic HTML document from
scratch, including the necessary elements
Objectives
Explain the fundamental structure of an HTML
document, including, elements, tags, and
attributes
Learning
including the necessary elements such as ‘<!
DOCTYPE>’, ‘,<html >’, ‘<head>’, and ‘<body>’
Learning
including the necessary elements such as ‘<!
DOCTYPE>’, ‘,<html >’, ‘<head>’, and ‘<body>’
A Simple
<head>
<title>Page Title</title>
</head>
HTML <body>
</body>
</html>
The <!DOCTYPE html> declaration defines that this
document is an HTML5 document
The <html> element is the root element of an HTML
page
The <head> element contains meta information about
Explained tab)
The <body> elements defines the document’s body, and
is a container for all the visible contents, such as
headings, paragraphs, images, hyperlinks, tables, lists,
etc.
The <h1> element defines a large heading
The <p> elements defines a paragraph
The HTML element is defined by a start tag, some
content, and an end tag:
What is <tagname>Content goes here…</tagname>
WEB
Browsers
HTML Page Structure
HTML History
Year Version
1989 Tim Berners-Lee invented www
1991 Tim Berners-Lee invented HTML
1993 Dave Raggett drafted HTML+
1995 HTML Working Group defined HTML 2.0
1997 W3C Recommendation: HTML 3.2
1999 W3C Recommendation: HTML 4.01
2000 W3C Recommendation: XHTML 1.0
HTML History
Year Version
2008 WHATWG HTML5 First Public Draft
2012 WHATWG HTML5 Living Standard
2014 W3C Recommendation: HTML 5
2016 W3C Recommendation: HTML 5.1
2017 W3C Recommendation: HTML 5.1 2nd Edition
2017 W3C Recommendation: HTML 5.2
HTML Versions
• Since the early days of the web, there have been many versions of HTML
Year Version
1991 HTML
1995 HTML 2.0
1997 HTML 3.2
1999 HTML 4.01
2000 XTML
2014 HTML5
HTML Step 1: Open Notepad
Editors
• Open the Start Screen (Start Button)
• Then look for Notepad
Learn HTML
using Notepad
or TextEdit
Step 2: Write Some HTML
HTML Code
Editors <!DOCTYPE html>
<html>
<body>
Learn HTML
using Notepad
or TextEdit
Step 3: View the HTML
HTML Page in your browser
• Open the saved HTML file in your favorite
Editors browser (double click on the file, or right-click
– and choose “Open with”)
Learn HTML
using Notepad
or TextEdit
All HTML documents must start with a
document type declaration: <!DOCTYPE
html>
HTML The HTML document itself begins with
Documents <html> and ends with </html>
The visible part of the HTML document is
between <body> and </body>
Example
<!DOCTYPE html>
HTML <html>
<body>
Basic
<h1>My First Heading</h1>
Examples <p>My first paragraph.</p>
</body>
</html>
The <!DOCTYPE html> declaration
represents the document type, and helps
browsers to display web pages correctly
The <! The <!DOCTYPE html> declaration is not
DOCTYPE> case sensitive
HTML
<p> This is a paragraph </p>
Paragraph <p> This is another paragraph </p>
HTML links are defined with the <a> tag
HTML
Links The link’s destination is specified in the href
attribute
Attributes are used to provide additional
information about HTML elements
HTML images are defined with the <img> tag
The source file (src), alternative text (alt), width and
height are provided as attributes
HTML
Images
An HTML element is defined by a start tag, some
content, and end tag
HTML element is everything from the start tag to the
end tag
HTML
Elements
HTML
Elements
HTML elements can be nested (this means that
elements can contain other elements)
All HTML documents consist of nested HTML
Nested
elements
HTML
Elements
The <html> element is the root element and it defines
the whole HTML document
Nested It has a start tag <html> and an end tag </html>
Then, inside the <html> element there is a <body>
HTML
element
Elements
(example
explained)
The <body> element defined the document’s body
Nested It has a start tag <body> and an end tag </body>
Then, inside the <body> element there are two other
Elements
(example
explained)
All HTML elements can have attributes
Attributes provide additional information about
HTML elements
Attributes are always specified in the start tag
Attributes usually come in name/value pairs like:
Attributes name=“value”
The <a> tag defines a hyperlink
The href attributes specifies the URL of the page the
link goes to
href
Attributes
The <img> tag is used to embed an image in an HTML
page.
The src attributes specifies the path to the image to
src
be displayed
Attributes
The <img> tag should also contain the width and
Width height attribute, which specify the width and height
of the image
and
height
Attributes
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 a slow
connection, or an error in the src attribute
Alt
Attributes
The style attribute is used to add styles to an element,
such as color, font, size, and more
style
Attributes
A paragraph always starts on a new line, and a
browsers automatically add some white space
(a margin) before and after a paragraph
HTML
<p> This is a paragraph </p>
Paragraph <p> This is another paragraph </p>
You cannot be sure how HTML will be displayed
Large or small screens, and resized windows
will create different results
With HTML, you cannot change the display by
Horizontal
Rules
The HTML <br> element defines a line break
Use <br> if you want a line break (a new line)
without starting a new paragraph
HTML
Line Break
The Poem Problem
HTML
Line Break
The HTML <pre> element defines preformatted
text
The text inside a <pre> element is displayed in
a fixed-width font (usually courier), and it
<pre>
Element
The HTML style attribute is used to add styles
to an element, such as color, font, size, and
more
HTML
Style
Attribute
The HTML style attribute has the following
syntax
HTML
Style
Attribute
The CSS background-color property defines the
background color for an HTML element
Background
Color
Setting background color for two different
elements
Background
Color
The CSS color property defines the text color
for an HTML element
Text color
The CSS font-family property defines the font to
be used for an HTML element
Fonts
The CSS font-size property defines the text size
for an HTML element
Text Size
The CSS text-align property defines the
horizontal text alignment for an HTML element
Text
Alignment
HTML contains several elements for defining
text with a special meaning
HTML Text
Formatting
Formatting elements were designed to display
special types of text:
HTML
Formatting
Elements
The HTML <b> elements defines bold text,
and
<strong>
elements
The HTML <strong> element defines text with
strong importance.
HTML <b> The content inside is typically displayed in bold
and
<strong>
elements
The HTML <i> element defines part of text in an
alternate voice or mood. The content inside
HTML <i> typically displayed in italic
and <em>
elements
The HTML <em> element defines emphasized
text. The content inside typically displayed in
HTML <i> italic
and <em>
elements
The HTML <small> element defines smaller text
HTML
<small>
Element
The HTML <mark> element defines text that
<mark>
Element
The HTML <del> element defines text that has been
deleted from a document. Browsers will usually
strike a little through deleted text
HTML <del>
Element
The HTML <ins> element defines a text that has been
inserted into a document. Browsers will usually
underline inserted text
HTML <ins>
Element
HTML colors are specified with predefined color
names, or with RGB, HEX, HSL, RGBA, or HSLA valued
HTML Colors
HTML colors are specified with predefined color
names, or with RGB, HEX, HSL, RGBA, or HSLA valued
HTML Colors
(sample
output)
You can set the background color for HTML elements
Background
Color
Background
Color
(sample
output)
Text Color
Text Color
(sample
output)
Border Color
Border Color
(sample
output)
In HTML, colors can also be specified using RGB
values, HEX values, HSL values, RGBA values, and
HSLA values
The following three <div> elements have their
background color set with RGB, HEX, and HSL values
Color Values
The following two <div> elements have their
background color set with RGBA and HSLA values,
which add an Alpha channel to the color (here we
have 50% transparency)
Color Values
Color Values
(sample
code)
An RGB color value represents RED, GREEN, and
HTML RGB BLUE light sources
An RGBA color value is an extension of RGB with an
and RGBA Alpha channel
Colors
In HTML, a color can be specified as an RGB value,
using this formula
RGB Color • rgb(red, green, blue)
Values
HTML tables allow web developers to arrange data
into rows and columns
HTML Table
HTML Table
(example)
HTML Table
(example)
HTML Table
(example)
HTML Table
(example)
A table in HTML consist of table cells inside rows and
Define an columns
HTML Table
(example)
(Sample
Output)
Each table cell is defined by a <td> and a </td> tag
td stands for table data
Everything between <td> and </td> are the content
Table cells of the table cell
(example)
(Sample
Output)
Each table row starts with a <tr> and ends with a
</tr> tag
tr stands for table row
Table rows
(example)
(Sample
Output)
Sometimes you want your cells to be table header
cells. In those cases use the <th> tag instead of the
Table <td> tag
th stands for table header
Headers
(example)
(Sample
Output)
Using Emojis
in HTML
(example)
(Sample
Output)