HTML Slides
HTML Slides
to
Bright Future Institute
Muneer Ahmed Khan
HTML
1
Outline
2
HTML stands for Hyper Text Markup Language
HTML is the standard markup language for creating web pages
HTML describe the structure of a web pages
HTML consist of series of elements
HTML elements tell the browser how to display the content
HTML elements label pieces of content such as “this is a
heading”, “this is a paragraph”, “this is a link”, etc.
3
Atom Froala
Notepad CoffeeCup
4
HTML Documents
• All HTML documents must start with a document type declaration:
<!DOCTYPE html>.
• The HTML document itself begins with <html> and end with </html>.
5
Example
<!DOCTYPE html> Output
<html>
This is heading.
<body>
This is paragraph.
<h1> This is heading. </h1>
<p> This is paragraph. </p>
</body>
</html>
6
The <!DOCTYPE> Declaration
• The <!DOCTYPE> declaration represents the document type, and help
browsers to display web pages correctly.
• Its only appear once, at the top of the page (before any HTML
tags).
<!DOCTYPE html>
7
The HTML element is everything from the start tag to the
end tag:
<tagname>Content goes here…</tagname>
Note: Some HTML elements have no content (like the <br> element).
These elements are called empty elements.
Empty elements do not have an end tag!
8
Nested HTML Elements
• HTML elements can be nested (this means that elements can
contain other elements).
9
• All HTML elements can have attributes
• Attribute provide additional information about elements.
• Attributes are always specified in the start tag.
Lang Attributes
You should always include the lang attribute inside the <html> tag, to
declare the language of the Web page.
This is meant to assist search engines and browsers.
<html lang=“en”>…..</html>
10
• HTML headings are titles or subtitles that you want to display
on a webpage.
• HTML headings are defined with the <h1> to <h6> tags.
• <h1> defines the most important heading. <h6> defines the
least important heading.
Example
<h1> Heading 1 </h1>
<h2> Heading 2 </h2>
<h3> Heading 3 </h3>
<h4> Heading 4 </h4>
<h5> Heading 5 </h5>
<h6> Heading 6 </h6>
11
Headings Are Important
• 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.
Note: Use HTML headings for heading only. Don’t use headings to make
text BIG or bold.
12
• 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
13
HTML Display
• You cannot be sure how HTML will be displayed.
• Large or small screens, and resized windows will create
different result.
• With HTML, you cannot change the display by adding extra
spaces or extra lines in your HTML code.
• The browser will automatically remove any extra spaces and
lines when the page is displayed.
14
Example
<p> <p>
This is paragraph This is paragraph
Contains a lot of lines Contains a lot of spaces
In the source code, In the source code,
But the browser But the browser
Ignores it. Ignores it.
</p> </p>
15
• The <hr> tag defines a thematic break in an HTML page, and is
most often displayed as a horizontal rule.
Example
<h1> This is heading 1 </h1>
<p> This is some text. </p>
<hr>
<h2> This is heading 2 </h2>
<p> This is some other text. </p>
• The <hr> tag is an empty tag, which means that it has no end tag.
16
• Use <br> if you want a line break (a new line) without starting a
new paragraph.
Example
• The <br> tag is an empty tag, which means that it has no end tag.
17
• The HTML <pre> element defines preformatted text.
• The text inside a <pre> element is displayed in fixed-width
font(usually Courier), and it preserves both space and line break.
Example
<pre>
My Bonnie lies over the ocean.
18
• The HTML style attribute is used to add styles to an element, such
as color, font size, and more.
Example
I am Red
I am Blue
I am Big
<tagname style=“property:value;”>
• The property is CSS property. The value is CSS value.
19
HTML contains several elements for defining text with a special
meaning.
• <b> • <small>
• <strong> • <del>
• <i> • <ins>
• <em> • <sub>
• <mark> • <sup>
20
We will go through the HTML Quotations elements:
• <blockqoute> • <cite>
• <q> • <bdo>
• <abbr>
• <address>
21
HTML comments are not displayed in the browser, but they can
help document your HTML source code.
You can add comments to your HTML source by using the following
syntax:
<!-- Write your comments here -->
Notice that there is an exclamation point (!) in the start tag, but
not in the end tag.
22
Links are found in nearly all web pages. Links allow users to click their
way from page to page.
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.
A link does not have to be text. A link can be an image or any other
HTML elements.
The HTML <a> tag defines a hyperlink. It has the following syntax:
23
The Target Attributes
o By default, the linked page will be displayed in the current
browser window. To change this, you must specify another
target for the link.
o The target attribute specifies where to open the linked document.
o The target attribute can have one of the following values:
• _self • _parent
• _top
• _blank
Syntax:
<a href=“url" target="_blank">link text</a>
24
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.
The <img> tag has two required attributes:
• src • alt
Syntax:
<img src="url" alt="alternatetext">
25
A favicon is a small Image displayed next to the page title in the
browser tab.
Syntax:
26
HTML tables allow web developers to arrange data into rows and
columns.
27
HTML tables can have cells that spans over multiple rows and/or
columns.
To make a cell span over multiple columns, use the colspan attribute:
To make a cell span over multiple rows, use the rowspan attribute:
<tr> <tr>
<th colspan="2">Name</th> <th rowspan="2">Name</th>
<th>Age</th> <th>Age</th>
</tr> </tr>
28
HTML lists allow web developers to group a set of related items in
lists.
Example:
An unordered HTML list: An ordered HTML list:
An unordered list starts with the <ul> tag. Each list item starts with
the <li> tag.
29
An ordered list starts with the <ol> tag. Each list item starts with
the <li> tag.
Description Lists:
HTML also supports description lists.
A description list is a list of terms, with a description of each
term.
The <dl> tag defines the description list, the <dt> tag defines
the term (name), and the <dd> tag describes each term:
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
30
Block-level Elements:
A block-level element always starts on a new line, and the
browsers automatically add some space (a margin) before and
after the element.
A block-level element always takes up the full width available
(stretches out to the left and right as far as it can).
Two commonly used block elements are: <p> and <div>.
The <p> element defines a paragraph in an HTML document.
The <div> element defines a division or a section in an HTML
document.
Here are the some block-level elements in HTML:
<dd> <div> <p> <ul> <li> <pre> <hr> etc.
31
Inline Elements:
An inline element does not start on a new line.
32
Classes:
The HTML class attribute is used to specify a class for an
HTML element.
Example:
<p class=“para”> This is paragraph </p>
33
ID:
The HTML id attribute is used to specify a unique id for an
HTML element.
You cannot have more than one element with the same id in
an HTML document.
The id name is case sensitive!
The id name must contain at least one character, cannot start
with a number, and must not contain whitespaces (spaces,
tabs, etc.).
Example:
<h1 id=“heading”> This is First Heading. </h1>
34
Reserved characters in HTML must be replaced with character
entities.
If you use the less than (<) or greater than (>) signs in your text, the
browser might mix them with tags.
Character entities are used to display reserved characters in HTML.
35
Some Useful HTML Character Entities
36
Emojis look like images, or icons, but they are not.
Emojis are characters from the UTF-8 character set: 😄 😄 😄
UTF-8 covers almost all of the characters and symbols in the world.
Example:
37
An HTML form is used to collect user input. The user input is most
often sent to a server for processing.
The HTML <form> element is used to create an HTML form for user
input:
Example
<form>
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname">
</form>
38
The HTML <video> element is used to show a video on a web
page.
To start a video automatically, use the autoplay attribute:
Example:
39
BEST OF LUCK
40