Professional Documents
Culture Documents
HTML
HTML
HTML
1
What is HTML?
5
<!DOCTYPE html>
The HTML document type declaration, also
known as DOCTYPE, is the first line of code
required in every HTML . The DOCTYPE
declaration is an instruction to the web browser
about what version of HTML the page is written
in. This ensures that the web page is parsed the
same way by different web browsers.
6
Example Explained
7
Types of tag
There are two types of tags:
1.Paired Tags
2.Unpaired Tags
1.A paired tag consist of two tags, first one is called an opening tag and the second one is called a
closing tag. These tags contains the text in between at which the effect of that tag will be applied.
Example: <b>ABC</b>
Here <b> is the opening tag, </b> is the closing tag and ABC the text in between which will
result as ABC on the browser screen.
Examples:
<i> </i>
<ul> </ul>
<h1> </h1> , etc.
2.An Unpaired tag is a single tag which does not need a companion tag.
These tags can be written like < > or < /> both works as same, it’s your choice which style you
choose.
Example:
<br> or <br />
<hr> or <hr />
8
HTML Headings
<h1> defines the most important heading. <h6> defines the least
important heading:
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
9
10
HTML Paragraphs
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
11
LINE BREAK <br>
12
Horizontal Rule, <HR>
13
<PRE>TAG
14
How to add comment In HTML
<! -- Write commented text here -->
15
HTML Formatting Elements
16
The HTML <i> element defines a part of text in an
alternate voice or mood. The content inside is typically
displayed in italic.
<i>This text is italic</i>
The HTML <strong> element defines text with strong
importance. The content inside is typically displayed in
bold.
<strong>This text is important!</strong>
17
The HTML <sub> element defines subscript text.
Subscript text appears half a character below the normal line,
and is sometimes rendered in a smaller font. Subscript text can be
used for chemical formulas, like H2O:
Example
<p>This is <sub>subscripted</sub> text.</p>
The HTML <sup> element defines superscript text.
Superscript text appears half a character above the normal line,
and is sometimes rendered in a smaller font. Superscript text can be
used for footnotes, like WWW[1]:
Example
<p>This is <sup>superscripted</sup> text.</p>
18
mark
The HTML <mark> element defines text that
should be marked or highlighted:
<!DOCTYPE html>
<html>
<body>
<p>Do not forget to buy <mark>milk</mark>
today.</p>
</body>
</html>
Do not forget to buy milk today.
19
The <small> tag defines smaller text (like
copyright and other side-comments).
<!DOCTYPE html>
<html>
<body>
<h1>The small element</h1>
<p>This is some normal text.</p>
<p><small>This is some smaller
text.</small></p>
</body>
</html>
20
delete
<!DOCTYPE html>
<html>
<body>
<p>My favorite color is <del>blue</del> </p>
</body>
</html>
In output blue is strike marked
21
insert
HTML <ins> Element
The HTML <ins> element defines a text that has been inserted into a
document.
Browsers will usually underline inserted text:
<p>My favorite color is <del>blue</del> <ins>red</ins>.</p>
<!DOCTYPE html>
<html>
<body>
<p> My favorite color is <del> blue </del> <ins> red </ins> </p>
</body>
</html>
22
The <sub> tag defines subscript text. Subscript text appears half a character
below the normal line, and is sometimes rendered in a smaller font. Subscript
<!DOCTYPE html>
<html>
<body>
<h1>The sub and sup elements</h1>
<p>This text contains <sub>subscript</sub> text.</p>
<p>This text contains <sup>superscript</sup> text.</p>
</body>
</html>
23
HTML Attributes
name="value"
24
image tag
25
HTML ANCHOR TAG
26
Attributes of HTML img tag
The src and alt are important attributes of HTML img tag.
1) src
It is a necessary attribute that describes the source or path of the image. It instructs the
browser where to look for the image on the server.
The location of image may be on the same directory or another server.
2) alt
The alt attribute defines an alternate text for the image, if it can't be displayed. The value of
the alt attribute describe the image in words. The alt attribute is considered good for
SEO(search engine optimazation) prospective.
3) width
It is an optional attribute which is used to specify the width to display the image. It is not
recommended now. You should apply CSS in place of width attribute.
4) height
It h3 the height of the image. The HTML height attribute also supports iframe, image and
object elements. It is not recommended now. You should apply CSS in place of height
attribute.
27
Anchor tag to link one image
BY USING ANCHOR TAG WE CAN LINK ONE IMAGE FILE TO HTML FILE
28
ANCHOR TAG
BY USING ANCHOR TAG WE CAN LINK ONE HTML TO ANOTHER HTML FILE
29
ANCHOR TAG TO LINK WEBSITE
BY USING ANCHOR TAG WE CAN LINK ONE WEBSITE FILE TO HTML FILE
30
CHANGING BACKGROUND COLOR IN
HTML
31
1.Background Color
32
33
34
CSS EFFECT
35
The style Attribute
36
Text Color
The CSS color property defines the text color for an HTML element:
Example
<h1 style="color:blue;">This is a heading</h1>
<p style="color:red;">This is a paragraph.</p>
37
Color Codes
Colors are set using “RGB” color codes, which are,
represented as hexadecimal values. Each 2-digit section
of the code represents the amount, in sequence, of red,
green or blue that forms the color. For example, a RGB
value with 00 as the first two digits has no red in the
color.
38
RGB Colour Model
39
Main Colours
40
TEXT Color
The TEXT attribute is used to control the color of all the normal text in the document.
The default color for text is black. The TEXT attribute would be added as follows:
<BODY BGCOLOR=“#FFFFFF” TEXT=“#FF0000”></BODY>
In this example the document’s page
color is white and the text would be red.
41
Without color codes
42
Color Codes
1. WHITE 1. #FFFFFF
2. BLACK 2. #000000
3. RED 3. #FF0000
4. GREEN 4. #00FF00
5. BLUE 5. #0000FF
6. MAGENTA 6. #FF00FF
7. CYAN 7. #00FFFF
8. YELLOW 8. #FFFF00
9. AQUAMARINE 9. #70DB93
10. BAKER’S CHOCOLATE 10. #5C3317
11. VIOLET 11. #9F5F9F
12. BRASS 12. #B5A642
13. COPPER 13. #B87333
14. PINK 14. #FF6EC7
15. ORANGE 15. #FF7F00
43
Internal Links
Internal Links : Links can also be created inside large
documents to simplify navigation. Today’s world wants to be
able to get the information quickly. Internal links can help
you meet these goals.
1. Select some text at a place in the document that you would
like to create a link to, then add an anchor to link to like this:
<A NAME=“bookmark_name”></A>
The Name attribute of an anchor element specifies a location
in the document that we link to shortly. All NAME attributes
in a document must be unique.
2. Next select the text that you would like to create as a link to
the location created above.
<A HREF=“#bookmark_name”>Go To Book Mark</A>
44
LINK, VLINK, and ALINK
45
EXAMPLE
46
Fonts
Example
<h1 style="font-family:verdana;">This is a heading</h1>
<p style="font-family:courier;">This is a paragraph.</p>
47
Text Size
48
Text Alignment
Example
49
EXAMPLE
50
division <div> tag
<div> tag defines a division or a section in an html document.
The <div> element is often used as a container for other html elements.
By default browsers always place a line break before and after the <div> element.
However this can be changed with CSS.
<span> tag
53
54
bydefault
55
56
Type=“none”
57
NESTED UNORDERDHTML LISTS
58
59
60
Bydefault
61
EXAMPLE
62
EXAMPLE
63
HTML Description Lists
.
A description list is a list of terms, with a description of each term.
64
TABLE
65
Tables
In this chapter you will learn that tables have many uses in
HTML.
Objectives:
Upon completing this section, you should be able to:
1. Insert a table.
2. Explain a table’s attributes.
3. Edit a table.
4. Add a table header.
66
67
Example1
68
HTML Table with Border
69
Example 1 HTML Border attribute
70
Example 2 CSS Border property
71
TABLE WITH CAPTION
<html>
<head><title>table</title>
</head>
<body>
<table border="1">
<caption>marks</caption>
<tr><th>name</th><th>subject1</th><th>subject2</th></
tr>
<tr><td>bibhu</td><td>50</td><td>60</td></tr>
<tr><td>litu</td><td>70</td><td>65</td></tr>
</table>
</body>
</html>
72
Table Attributes
CellSpacing: Cell spacing is the space between
each cell.
CellPadding: Cell Padding is the space between
the cell border and the cell contents and is specified in
pixels.
73
HTML Table with cell padding
74
Cell padding property in css
75
Table Data and Table Header Attributes
Colspan: Specifies how many cell columns of the table this cell
should span.
Rowspan: Specifies how many cell rows of the table this cell
should span.
Align: cell data can have left, right, or center alignment.
Valign: cell data can have top, middle, or bottom alignment.
Width: you can specify the width as an absolute number of pixels
or a percentage of the document width.
Height: You can specify the height as an absolute number of pixels
or a percentage of the document height.
76
HTML Table with colspan
If you want to make a cell span more than one column, you can use the colspan attribute.
It will divide one cell/row into multiple columns, and the number of columns depend on the value of colspan attribute.
77
HTML Table with rowspan
If you want to make a cell span more than one row, you can use the rowspan attribute.
It will divide a cell into multiple rows. The number of divided rows will depend on rowspan values.
78
EXAMPLE
<html>
<head><title>table</title>
</head>
<body>
<table border="1">
<caption>marks</caption>
<tr>
<th rowspan=2>name</th>
<th colspan=2>marks</th>
</tr>
<tr><th>subject1</th><th>subject2</th></tr>
<tr><td>bibhu</td><td>50</td><td>60</td></tr>
<tr><td>litu</td><td>70</td><td>65</td></tr>
</table>
</body>
</html>
79
EXAMPLE
<html>
<head><title>table</title>
</head>
<body>
<table border="1">
<caption>marks</caption>
<tr>
<th colspan=2>marks</th>
<th rowspan=2>name</th>
</tr>
<tr><th>subject1</th><th>subject2</th></tr>
<tr><td>bibhu</td><td>50</td><td>60</td></tr>
<tr><td>litu</td><td>70</td><td>65</td></tr>
</table>
</body>
</html>
80
Special Things to Note
81
EXAMPLE
82
83
Example
84
85
Frames
86
What is frames
HTML frames are used to divide your browser window into
multiple sections where each section can load a separate HTML
document. A collection of frames in the browser window is known
as a frameset. The window is divided into frames in a similar way
the tables are organized: into rows and columns.
Disadvantages of Frames
There are few drawbacks with using frames, so it's never
recommended to use frames in your webpages −
Some smaller devices cannot cope with frames often because their
screen is not big enough to be divided up.
Sometimes your page will be displayed differently on different
computers due to different screen resolution.
The browser's back button might not work as the user hopes.
There are still few browsers that do not support frame technology.
87
Creating Frames
To use frames on a page we use <frameset> tag instead of
<body> tag. The <frameset> tag defines, how to divide the
window into frames. The rows attribute of <frameset> tag
defines horizontal frames and cols attribute defines vertical
frames. Each frame is indicated by <frame> tag and it defines
which HTML document shall open into the frame.
Note − The <frame> tag deprecated in HTML5. Do not use
this element.
88
Frames
Doc1.html Doc2.html
Doc1.html Doc2.html
Frames.html
89
Example
<!DOCTYPE html>
<html>
<head>
<title>Frame tag</title>
</head>
<frameset cols="25%,50%,25%">
<frame src="frame1.html" >
<frame src="frame2.html">
<frame src="frame3.html">
</frameset>
</html>
90
91
Example 2 Create Horizontal frames:
<!DOCTYPE html>
<html>
<head>
<title>Frame tag</title>
</head>
<frameset rows="30%, 40%, 30%">
<frame name="top" src="frame1.html" >
<frame name="main" src="frame2.html">
<frame name="bottom" src="frame3.html">
</frameset>
</html>
92
Frame Page Architecture
<FRAME>: This element defines a single frame within a frameset. There will be a
FRAME element for each division created by the FRAMESET element. This tag has
the following attributes:
SRC: Required, as it provides the URL for the page that will be displayed in the
frame.
NAME: Required for frames that will allow targeting by other HTML documents.
Works in conjunction with the target attribute of the <A>, <AREA>, <BASE>, and
<FORM> tags.
A <FRAMESET> element is placed in the html document before the <BODY>
element. The <FRAMESET> describes the amount of screen real estate given to each
windowpane by dividing the screen into ROWS or COLS.
The <FRAMESET> will then contain <FRAME> elements, one per division of the
browser window.
Note: Because there is no BODY container, FRAMESET pages can't have
background images and background colors associated with them.
93
Compound FRAMESET Divisions Example
<HEAD>
<FRAMESET ROWS="25%,50%,25%”
<FRAME SRC="">
<FRAMESET COLS="25%,*">
<FRAME SRC="">
<FRAME SRC="">
</FRAMESET>
<FRAME SRC="">
</FRAMESET>
</HEAD>
94
<FRAMESET> Container
<FRAMESET> : The FRAMESET element creates
divisions in the browser window in a single direction.
This allows you to define divisions as either rows or
columns.
ROWS : Determines the size and number of rectangular
rows within a <FRAMESET>. They are set from top of
the display area to the bottom.
Possible values are:
Absolute pixel units, I.e. “360,120”.
A percentage of screen height, e.g. “75%,25%”.
Proportional values using the asterisk (*). This is often
combined with a value in pixels , e.g. “360,*”.
95
Creating a Frames Page
FRAMEBORDER : Possible values 0, 1, YES, NO. A
setting of zero will create a borderless frame.
FRAMESPACING: This attribute is specified in pixels.
If you go to borderless frames you will need to set this
value to zero as well, or you will have a gap between
your frames where the border used to be.
BORDER(thickness of the Frame): This attribute
specified in pixels. A setting of zero will create a
borderless frame. Default value is 5.
BORDERCOLOR: This attribute is allows you choose
a color for your border. This attribute is rarely used.
96
<FRAME>
97
<NOFRAMES>
<NOFRAMES>: Frame – capable browsers ignore all HTML within this tag including
the contents of the BODY element. This element does not have any attributes.
<HTML>
<HEAD>
<TITLE> Framed Page </TITLE>
</HEAD>
98
99
100
101
What do the following mean?
1)<FRAMESET COLS="2*, 3*, 5*">
2) <FRAMESET COLS="150, 20%, *, 3*">
So what are the space-allocation priorities? Absolute pixel
values are always assigned space first, in order from
left to right. These are followed by percentage values
of the total space. Finally, proportional values are
divided based upon what space is left.
102
Forms
Forms add the ability to web pages to not only provide the person
viewing the document with dynamic information but also to
obtain information from the person viewing it, and process the
information.
Objectives:
Upon completing this section, you should be able to
1. Create a FORM.
2. Add elements to a FORM.
3. Define CGI (Common Gateway Interface).
4. Describe the purpose of a CGI Application.
5. Specify an action for the FORM.
Forms work in all browsers.
Forms are Platform Independent.
103
Sami Ali
Al al-Bayt University
104
105
HTML FORM
106
HTML FORM TAG
107
The <input> Element
The HTML <input> element is the most used form element.
An <input> element can be displayed in many ways, depending on the type
attribute.
Type Description
<input type="text"> Displays a single-line text input field
<input type="radio"> Displays a radio button (for selecting one of many choices)
<input type="checkbox"> Displays a checkbox (for selecting zero or more of many
choices)
<input type="submit"> Displays a submit button (for submitting the form)
<input type="button"> Displays a clickable button
108
<input> tag text
The <input> tag specifies an input field where the user can enter data.
The <input> element is the most important form element.
The <input> element can be displayed in several ways, depending on the
type attribute.
<!DOCTYPE html>
<html>
<body>
<form>
Enter your name<br>
<input type="text" name ="username">
</form>
</body>
</html>
109
<!DOCTYPE html>
<html>
<body>
<form>
<br>
<label for="myname">Enter your name</label><br>
<input type="text" id ="myname"name ="text">
</form>
</body>
</html>
110
button
<!DOCTYPE html>
<html>
<body>
<form>
Enter your name<br>
<input type="button" name ="button">
</form>
</body>
</html>
111
submit
Click the "Submit" button for sending the form-data to a page on
the server.
112
hidden
Definition and Usage
The <input type="hidden"> defines a hidden input field.
A hidden field lets web developers include data that cannot be seen or modified by users when a form is
submitted.
A hidden field often stores what database record that needs to be updated when the form is submitted.
Note: While the value is not displayed to the user in the page's content, it is visible (and can be edited) using
any browser's developer tools or "View Source" functionality. Do not use hidden inputs as a form of
security!
113
file
114
password
115
RADIO BOTTON
<html>
<head>RADIO BOTTON
<HR>
</head>
<body>
<form>
Gender==============================
<br>
<input type="radio" name="Gender" >MALE<br>
<input type="radio" name="Gender" >FEMALE<br>
</form>
</body>
</html>
116
<label> tag
Definition and Usage
The <label> tag defines a label for several elements:
Proper use of labels with the elements above will benefit:
Screen reader users (will read out loud the label, when the
user is focused on the element)
Users who have difficulty clicking on very small regions
(such as checkboxes) - because when a user clicks the text
within the <label> element, it toggles the input (this increases
the hit area).
117
118
Radio button with label tag
<html>
<head>RADIO BOTTON
<HR>
</head>
<body>
<form>
Gender==============================
<br>
<label for="MALE">MALE</label>
<input type="radio" name="Gender" id="MALE"><br>
<label for="FEMALE">FEMALE<label>
<input type="radio" name="Gender" id="FEMALE"><br>
</form>
</body>
</html>
119
radio button
120
checkbox
Checkboxes are used to give multiple options
121
TEXTAREA
122
Other Elements used in Forms
<TEXTAREA></TEXTAREA>: is an element
that allows for free form text entry.
123
reset
124
select
125
Other Elements used in Forms
The two following examples are <SELECT></SELECT> elements,
where the attributes are set differently.
The Select elements attributes are:
NAME: is the name of the variable to be sent to the CGI application.
SIZE: this sets the number of visible choices.
MULTIPLE: the presence of this attribute signifies that the user can
make multiple selections. By default only one selection is allowed.
126
<FORM> element attributes
127
Form Elements
<INPUT> Element’s Properties
128
What is Multimedia?
Later came browsers with support for colors, fonts, images, and multimedia!
Multimedia Formats
Multimedia elements (like audio or video) are stored in media files.
The most common way to discover the type of a file, is to look at the file
extension.
Example
<audio controls autoplay>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
130
The HTML <audio> Element
To play an audio file in HTML, use the <audio> element:
Example
<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
131
The HTML <video> Element
To show a video in HTML, use
the <video> element:
Example
<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
132
133
134
Blinking tag in javascript
135