Introduction To HTML - Developer
Introduction To HTML - Developer
What is HTML?
HTML is the standard markup language for creating Web pages.
HTML Versions
Version Year
HTML 1991
HTML 2.0 1995
HTML 3.2 1997
HTML 4.01 1999
XHTML 2000
HTML5 2014
HTML Tags
There are two types of tags..
o Container Tag / Pair Tag
o Singular Tag / Unpair Tag
Syntax :
HTML Structure
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
</html>
HTML Attributes
All HTML elements can have attributes
Attributes provide additional information about an element
Attributes are always specified in the start tag
Attributes usually come in name/value pairs like: name="value"
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body [bgcolor=“color-name”] => Set Background color for body
[text=“color-name”] => Set Text / Font Color in body
[link=“color-name”] => Set Link color in body
[alink=“color-name”] => Set Active Link color in body
[vlink=“color-name”] => Set Visited Link color in body
[background=“url”] > => Set a Background Image in body
</body>
</html>
Heading Tag
The <h1> element defines a large heading.
Syntax:
Example:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
</html>
Font Size :
Syntax :
BR Tag :
<br> => Break Row
Example:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
</html>
In the previous chapter, you learned about the HTML style attribute.
HTML also defines special elements for defining text with a special meaning.
HTML uses elements like <b> and <i> for formatting output, like bold or italic text.
Formatting elements were designed to display special types of text:
6 INTRODUCTION TO HTML
<address>
o The <address> tag defines the contact information for the author/owner of a
document or an article.
o The contact information can be an email address, URL, physical address, phone
number, social media handle, etc.
o Example:
<address>
Written by Creative.<br>
Visit us at:<br>
Example.com<br>
Box 564, Disneyland<br>
USA
</address>
o Output:
Written by Creative .
Visit us at:
Example.com
Box 564, Disneyland
USA
o Example:
<p>Price <strike>350$</strike> 300$</p>
<p>Price <del>350$</del> 300$</p>
<p>Price <s>350$</s> 300$</p>
o Output:
Price 350$ 300$
<sup>
o The <sup> tag defines superscript text.
o Superscript text appears half a character above the normal line, and is
sometimes rendered in a smaller font.
o Example:
<p>X <sup>2</sup></p>
o Output:
X2
<sub>
o The <sub> tag defines subscript text.
o Subscript text appears half a character below the normal line, and is sometimes
rendered in a smaller font.
o Example:
<p>H <sup>2</sup>O</p>
o Output:
H2O
<big>
o The <big> tag was used in HTML 4 to define bigger text.
o Example:
<p> This is a normal paragraph. </p>
<big> This is a bigger paragraph. </big>
9 INTRODUCTION TO HTML
o Output:
This is a normal paragraph.
This is a bigger paragraph.
<small>
o The <small> tag was used in HTML 4 to define smaller text.
o Example:
<p> This is a normal paragraph. </p>
<big> This is a smaller paragraph. </big>
o Output:
This is a normal paragraph.
This is a smaller paragraph.
<pre>
o The <pre> tag defines preformatted text.
o The text will be displayed exactly as written in the HTML source code.
o Example:
<pre> Text in a pre element
is displayed in a fixed-width
font, and it preserves
both spaces and
line breaks</pre>
o Output:
<font>
o The <font> tag was used in HTML 4 to specify the font face, font size, and color
of text.
o Syntax:
10 INTRODUCTION TO HTML
o Output:
11 INTRODUCTION TO HTML
<marquee>
o The <marquee> tag is a container tag of HTML is implemented for creating
scrollable text or images within a web page from either left to right or top to
bottom.
o Syntax:
<marquee [behavior=“Scroll | Slide | Alternate”]
[direction=“Left | Right | Up | Down”]
[loop=“1 | 2 | …N”]
[scrollamount=”number”]
[bgcolor=“Color Name”]
[height=“pixels”]
[width=“pixels”] >……</marquee>
o Example:
<marquee behavior="scroll" direction="up" scrollamount="1">Slow
Scrolling</marquee>
<marquee behavior="scroll" direction="right" scrollamount="12">Little
Fast Scrolling</marquee>
<marquee behavior="scroll" direction="left" scrollamount="20">Fast
Scrolling</marquee>
<marquee behavior="scroll" direction="right" scrollamount="50">Very
Fast Scrolling</marquee>
12 INTRODUCTION TO HTML
<a>
o The <a> tag defines a hyperlink, which is used to link from one page to another.
o The most important attribute of the <a> element is the href attribute, which
indicates the link's destination.
o Syntax:
<a [href=“URL”]
[target=“_blank”] >…</a>
o Example:
<a href="https://www.cdmi.in" target="_blank">Visit cdmi.in!</a>
o Output:
Visit cdmi.in
<img>
o The <img> tag is used to embed an image in an HTML page.
o The <img> tag has two required attributes:
src - Specifies the path to the image
alt - Specifies an alternate text for the image, if the image for some
reason cannot be displayed
o Syntax:
<img [alt=“AlternativeText]
[border=“border-width”]
[height=“pixels”]
[width=“pixels”]
[hspace=”pixels”] => Horizontal Margin
[vspace=“pixels”] > => Vertical Margin
o Example:
<img src=”your image path here” width=”500” border=”5” alt=”Creative
College” >
13 INTRODUCTION TO HTML
Tables in HTML
o The <table> tag defines an HTML table.
o An HTML table consists of one <table> element and one or more <tr>, <th>, and <td>
elements.
o The <caption> tag defines a Table Caption.
o The <tr> element defines a Table Row.
o The <th> element defines a Table Header.
o The <td> element defines a Table Cell.
<table> :
o Syntax:
<caption> :
o Syntax:
<tr> :
o To add a new row in a table we must use TR tag
o Syntax:
<tr bgcolor="color">………</tr>
16 INTRODUCTION TO HTML
<th> :
o The text in <th> elements are bold and centered.
o Each table header is defined with a <th> tag.
o Syntax:
The <form> element is a container for different types of input elements, such as: text
fields, checkboxes, radio buttons, submit buttons, etc.
Form Methods :
o GET :
Get method will DISPLAY all the information of page in to URL.
Note : Some of Browser will note display information on URL by
GET...
o POST :
POST method will HIDE all the information of page in to URL.
<input> Elements
Type Description
HTML Form Elements
<input type="text"> Displays a single-line text input field
<input type="password"> Displays text as a password
<input type="radio"> Displays a radio button (for selecting one of many choices)
Displays a checkbox (for selecting zero or more of many
<input type="checkbox">
choices)
<input type="submit"> Displays a submit button (for submitting the form)
20 INTRODUCTION TO HTML
o Syntax:
<input type=“Control Type”
[Name=“Name of Control”]
[Value=“DefaultValue”]
[MaxLength=“IntLen”]
[Size=“InputBoxLen”]
[ReadOnly][Disabled]
[Align=“Left|Right”]
[Checked=“Checked”] >
<textarea> :
o The <textarea> tag defines a multi-line text input control.
o The <textarea> element is often used in a form, to collect user inputs like
comments or reviews.
21 INTRODUCTION TO HTML
o The size of a text area is specified by the <cols> and <rows> attributes (or with
CSS).
o Syntax :
< textarea [Name=“Control Name”]
[Cols=“IntColumns”]
[Rows=“IntRows”]
[Disabled] [ReadOnly]
[Wrap=“Off | Physical”] >
Default Text…
</ textarea >
Example :
< textarea cols="22" rows="4" placeholder="Address"></ textarea >
<select> :
o The <select> element is used to create a drop-down list.
o The <select> element is most often used in a form, to collect user input.
o Syntax:
< select [Name=“Control Name”]
[Disabled] [Multiple]
[Size=“Input Num of Character”] >
<option>….</option>
</select>
<option> :
o The <select> element is used to create a drop-down list.
o The <select> element is most often used in a form, to collect user input.
o Syntax:
<option [Name=“Control Name”]
22 INTRODUCTION TO HTML
[Value=“Initial Value”]
[Selected]>…….</option>
Example :
Design a Student Data Entry Form using form and input elements.
23 INTRODUCTION TO HTML
HTML5 – Overview
o HTML5 is the next major revision of the HTML standard. HTML5 is a standard for
structuring and presenting content on the World Wide Web.
o HTML5 is a cooperation between the World Wide Web Consortium (W3C) and the
Web Hypertext Application Technology Working Group (WHATWG).
o Syntax:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<header>
Your Content Here...
</header>
<nav>
Your Content Here...
</nav>
<section>
<article>
Your Content Here...
</article>
<article>
Your Content Here...
</article>
<aside>
Your Content Here...
</aside>
</section>
<footer>
Your Content Here...
</footer>
</body>
</html>
24 INTRODUCTION TO HTML
Frames in HTML
o <iframe>:
o The <iframe> tag specifies an inline frame.
o An inline frame is used to embed another document within the current HTML
document.
o Syntax:
<iframe src="URL" width="pixel/percent" height="pixel">
</iframe>
o Example:
<iframe src="https://www.cdmi.in/" width="50%" height="700">
</iframe>
25 INTRODUCTION TO HTML
o Audio:
o The <audio> tag is used to embed sound content in a document, such as music
or other audio streams.
o There are three supported audio formats in HTML: MP3, WAV, and OGG.
o To play an audio file in HTML, use the <audio> element:
o Syntax :
<audio controls>
<source src="Your path here"
o Example :
<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
</audio>
o Output :
o Video:
o The <video> tag is used to embed video content in a document, such as a movie
clip or other video streams.
o The <video> tag contains one or more <source> tags with different video
sources. The browser will choose the first source it supports.
o Syntax :
<video controls autoplay loop muted width height>
<source src="Your path here"
26 INTRODUCTION TO HTML
o Example :