html body { margin-top: 50px !important; } #top_form { position: fixed; top:0; left:0; width: 100%; margin:0; z-index: 2100000000; -moz-user-select: none; -khtml-user-select: none; -webkit-user-select: none; -o-user-select: none; border-bottom:1px solid #151515; background:#FFC8C8; height:45px; line-height:45px; } #top_form input[name=url] { width: 550px; height: 20px; padding: 5px; font: 13px "Helvetica Neue",Helvetica,Arial,sans-serif; border: 0px none; background: none repeat scroll 0% 0% #FFF; }
HTML Tut
HTML Tut
HTML Tut
INTRODUCTION TO HTML
• HTML with CSS and JavaScript you will be able to create your own
interactive and dynamic website. But Now We will focus on HTML only in
this tutorial.
• The major points of HTML are given below:
• HTML stands for HyperText Markup Language.
• HTML is used to create web pages and web applications.
• HTML is widely used language on the web.
• We can create a static website by HTML only.
• Technically, HTML is a Markup language rather than a programming
language.
STRUCTURE OF HTML5
<!DOCTYPE>
<html>
<head>
<title>Web page title</title>
</head>
<body>
<!- -Html content -- >
</body>
</html>
What is HTML ?
• Hyper Text: HyperText simply means "Text within Text." A text that has a link
within it, is a hypertext. Whenever you click on a link which brings you to a new
webpage, you have clicked on a hypertext. HyperText is a way to link two or
more web pages (HTML documents) with each other.
NB: HTML is a markup language which is used for creating attractive web
pages with the help of styling, and which looks in a nice format on a web
browser. An HTML document is made of many HTML tags and each HTML tag
contains different content.
Example of HTML Syntax
1. <!DOCTYPE>
2. <html>
3. <head>
4. <title>Web page title</title>
5. </head>
6. <body>
7. <h1>Write Your First Heading</h1>
8. <p>Write Your First Paragraph.</p>
9. </body>
10. </html>
Description of HTML Example
• <!DOCTYPE>: It defines the document type or it instruct the browser about
the version of HTML.
• <html > :This tag informs the browser that it is an HTML document. Text
between html tag describes the web document. It is a container for all other
elements of HTML except <!DOCTYPE>
• <head>: It should be the first element inside the <html> element, which
contains the metadata(information about the document). It must be closed
before the body tag opens.
Continue..
• <title>: As its name suggested, it is used to add title of that HTML page
which appears at the top of the browser window. It must be placed inside the
head tag and should close immediately. (Optional)
• <body> : Text between body tag describes the body content of the page
that is visible to the end user. This tag contains the main content of the
HTML document.
• <h1> : Text between <h1> tag describes the first level heading of the
webpage.
• <p> : Text between <p> tag describes the paragraph of the webpage.
HTML Layout
HTML Layout Definitions
Every website has a specific layout to display content in a specific
manner.
HTML 1.0: The first version of HTML was 1.0 and it was released in1991.
HTML 2.0: This was the next version which was released in 1995.
HTML 3.2: HTML 3.2 version was published by W3C in early 1997.
HTML 4.01: HTML 4.01 version was released on December 1999.
HTML5 : HTML5 is the newest version of HyperText Markup language. The
first draft of this version was announced in January 2008.
Features of HTML
1) It is a very easy and simple language. It can be easily understood and modified.
2) It is very easy to make an effective presentation with HTML because it has a lot of
formatting tags.
3) It is a markup language, so it provides a flexible way to design web pages along with
the text.
4) It facilitates programmers to add a link on the web pages (by html anchor tag), so it
enhances the interest of browsing of the user.
5) It is platform-independent because it can be displayed on any platform like Windows,
Linux, and Macintosh, etc.
6) It facilitates the programmer to add Graphics, Videos, and Sound to the web pages
which makes it more attractive and interactive.
7) HTML is a case-insensitive language, which means we can use tags either in lower-
case or upper-case.
HTML text Editors
• An HTML file is a text file, so to create an HTML file we can use any text
editors.
• Text editors are the programs which allow editing in a written text, hence to
create a web page we need to write our code in some text editor.
• There are various types of text editors available which you can directly
download, but for a beginner, the best text editor is Notepad (Windows) or
TextEdit (Mac).
• After learning the basics, you can easily use other professional text editors
which are, Notepad++, Sublime Text, Visual Studio Code, etc.
Building blocks of HTML
An HTML document consist of its basic building blocks which are:
• Tags: An HTML tag surrounds the content and apply meaning to it. It is
written between < and > brackets.
Syntax: <tag name attribute_name= " attr_value"> content </ tag name>
Continue..
• Elements: An HTML element is an individual component of an HTML file. In an HTML file,
everything written within tags are termed as HTML elements.
HTML Tags List
• Unclosed HTML Tags {<br>, <hr>}
• HTML Text Tags {<p>, <h1>, <h2>, <h3>, <h4>, <h5>, <h6>, <strong>, <em>,
<abbr>, <acronym>, <address>, <blockquote>, <cite>, <q>, <code>, <ins>,
<del>, <dfn>}
• HTML Table Tags {table, tr, td, th, tbody, thead, tfoot, col, colgroup and
caption}
• HTML Form Tags {form, input, textarea, select, option, optgroup, button,
label, fieldset and legend}
1. <h1>Heading no. 1</h1>
2. <h2>Heading no. 2</h2>
3. <h3>Heading no. 3</h3>
4. <h4>Heading no. 4</h4>
5. <h5>Heading no. 5</h5>
6. <h6>Heading no. 6</h6>
HTML Paragraph
• HTML paragraph or HTML p tag is used to define a paragraph in a
webpage.
1. <p>This is first paragraph.</p>
2. <p>This is second paragraph.</p>
3. <p>This is third paragraph.</p>
HTML Phrase tag
• HTML phrase tags are special purpose tags, which defines the structural meaning of a block
of text or semantics of text. Following is the list of phrase tags
• The "href" attribute is the most important attribute of the HTML a tag. and
which links to destination page or URL.
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 prospective.
Continue..
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.
Example:
<img src="animal.jpg" height="180" width="300" alt="animal image">
HTML Table
• HTML table tag is used to display data in tabular form (row * column).
There can be many columns in a row.
• We can create a table to display data in tabular form, using <table> element,
with the help of <tr> , <td>, and <th> elements.
• In Each table, table row is defined by <tr> tag, table header is defined by
<th>, and table data is defined by <td> tags.
Tag Description <col> It is used with
<colgroup> element to
<table> It defines a table. specify column
properties for each
<tr> It defines a row in a column.
table.
<tr><th>First_Name</th><th>Last_Name</th><th>Marks</th></tr>
<tr><td>Sonoo</td><td>Jaiswal</td><td>60</td></tr>
<tr><td>James</td><td>William</td><td>80</td></tr>
<tr><td>Swati</td><td>Sironi</td><td>82</td></tr>
<tr><td>Chetna</td><td>Singh</td><td>72</td></tr>
</table>
HTML Lists
HTML Lists are used to specify lists of information. All lists may contain one or
more list elements.
There are three different types of HTML lists:
In the ordered HTML lists, all the list items are marked with numbers by default.
It is known as numbered list.
<ol>
<li>Aries</li>
<li>Bingo</li>
<li>Leo</li>
<li>Oracle</li>
</ol>
HTML Unordered List or Bulleted List
In HTML Unordered list, all the list items are marked with bullets. It is also
known as bulleted list.
<ul>
<li>Aries</li>
<li>Bingo</li>
<li>Leo</li>
<li>Oracle</li>
</ul>
HTML Description List or Definition List
HTML Description list is also a list style which is supported by HTML and
XHTML. It is also known as definition list where entries are listed like a
dictionary or encyclopedia.
Currently, there are three video formats supported for HTML video tag:
mp4
webM
ogg
HTML Video Tag Example
Let's see the code to play mp4 file using HTML video tag.
<video controls>
<source src="movie.mp4" type="video/mp4">
Your browser does not support the html video tag.
</video>
Let's see the example to play ogg file using HTML video tag.
<video controls>
<source src="movie.ogg" type="video/ogg">
Your browser does not support the html video tag.
</video>
Attributes of HTML Video Tag
Attribute Description
controls It defines the video controls which is
displayed with play/pause buttons.
<video width="320" height="240" controls autoplay loop>
<source src="movie.mp4" type="video/mp4">
Your browser does not support the html video tag.
</video>
HTML Audio Tag
HTML audio tag is used to define sounds such as music and other audio clips.
Currently there are three supported file format for HTML 5 audio tag.
1. mp3
2. wav
3. Ogg
HTML5 supports <video> and <audio> controls. The Flash, Silverlight and
similar technologies are used to play the multimedia items.
Web Browser Supports
Browser mp3 wav ogg
<audio controls>
<source src=“src_name" type="audio/mpeg">
Your browser does not support the html audio tag.
</audio>
Attributes of HTML Audio Tag
Attribute Description
controls It defines the audio controls which is
displayed with play/pause buttons.
• SVG is mostly used for vector type diagrams like pie charts, 2-Dimensional graphs
in an X,Y coordinate system etc.
• The <svg> element specifies the root of a SVG fragment. You can animate every
element and every attribute in SVG files
HTML SVG Circle Example
• Example to draw circle by svg tag.
<svg width="100" height="100">
<circle cx="50" cy="50" r="40" stroke="yellow" stroke-width="4" fill="red" />
</svg>
<svg width="200" height="100">
<rect width="200" height="100" stroke="yellow" stroke-width="4" fill="red" />
</svg>
HTML Form
• An HTML form is a section of a document which contains controls
such as text fields, password fields, checkboxes, radio buttons,
submit button, menus etc.
<form action="server url" method=“GET | POST">
//input controls e.g. textfield, textarea, radiobutton, button
</form>
HTML Form Tags
Tag Description
<form> It defines an HTML form to enter
inputs by the used side.
Syntax:
<form>
//Form elements
</form>
HTML <input> element
The HTML <input> element is fundamental form element. It is used to create form
fields, to take input from user. We can apply different input filed to gather different
information form user. Following is the example to show the simple text input.
Example:
<body>
<form>
Enter your name <br>
<input type="text" name="username">
</form>
</body>
HTML Date
The date is the value of the type attribute of an <input> element. It
creates a calendar that allows a user to choose the date. The resulting
value includes the day, month, and year.
Syntax:
<input type="Date">
HTML TextField Control
The type="text" attribute of input tag creates textfield control also known as
single line textfield control. The name attribute is optional, but it is required for
the server side component such as JSP, ASP, PHP etc.
<form>
First Name:
<input type="text" name="firstname"/> <br/>
Last Name:
<input type="text" name="lastname"/> <br/>
</form>
HTML <textarea> tag in form
The <textarea> tag in HTML is used to insert multiple-line text in a
form. The size of <textarea> can be specify either using "rows" or "cols"
attribute or by CSS.
<form>
Enter your address:<br>
<textarea rows="2" cols="20"></textarea>
</form>
Label Tag in Form
It is considered better to have label in form. As it makes the code
parser/browser/user friendly.
<form>
<label for="firstname">First Name: </label> <br/>
<input type="text" id="firstname" name="firstname"/> <br/>
<label for="lastname">Last Name: </label>
<input type="text" id="lastname" name="lastname"/> <br/>
</form>
HTML Password Field Control
The password is not visible to the user in password field control.
<form>
<label for="password">Password: </label>
<input type="password" id="password" name="password"/> <br/
>
</form>
HTML 5 Email Field Control
The email field in new in HTML 5. It validates the text for correct email
address.
You must use @ and . in this field.
<form>
<label for="email">Email: </label>
<input type="email" id="email" name="email"/> <br/>
</form>
Radio Button Control
The radio button is used to select one option from multiple options. It is
used for selection of gender, quiz questions etc.
<form>
<label for="gender">Gender: </label>
<input type="radio" id="gender" name="gender" value="male"/
>Male
<input type="radio" id="gender" name="gender" value="female"/
>Female <br/>
</form>
Checkbox Control
The checkbox control is used to check multiple options from given checkboxes.
<form>
Hobby:<br>
<input type="checkbox" id="cricket" name="cricket" value="cricket"/>
<label for="cricket">Cricket</label> <br>
<input type="checkbox" id="football" name="football" value="football"/>
<label for="football">Football</label> <br>
<input type="checkbox" id="hockey" name="hockey" value="hockey"/>
<label for="hockey">Hockey</label>
</form>
Submit button control
HTML <input type="submit"> are used to add a submit button on web page.
When user clicks on submit button, then form get submit to the server.
<input type="submit" value="submit">
Example:
<form>
<label for="name">Enter name</label><br>
<input type="text" id="name" name="name"><br>
<label for="pass">Enter Password</label><br>
<input type="Password" id="pass" name="pass"><br>
<input type="submit" value="submit">
</form>
HTML <fieldset> element:
The <fieldset> element in HTML is used to group the related information of a form. This
element is used with <legend> element which provide caption for the grouped elements.
<form>
<fieldset>
<legend>User Information:</legend>
<label for="name">Enter name</label><br>
<input type="text" id="name" name="name"><br>
<label for="pass">Enter Password</label><br>
<input type="Password" id="pass" name="pass"><br>
<input type="submit" value="submit">
</fieldset>
</form>
HTML STYLE USING CSS
Style Using CSS
• CSS is used to apply the style in the web page which is made up of
HTML elements. It describes the look of the webpage.
• Inline CSS: Define CSS properties using style attribute in the HTML elements.
Inline CSS is used to apply CSS in a single element. It can apply style uniquely in each element.
• External CSS: Define all CSS property in a separate .css file, and then include the file with
<body style="text-align: center;">
<h2 style="color: red;">Welcome to html</h2>
<p style="color: blue; font-size: 25px; font-
style: italic ;">This is a great website to learn technologies in very simple
way. </p>
</body>
Class Attribute in HTML
• The HTML class attribute is used to specify a single or multiple class names
for an HTML element. The class name can be used by CSS and JavaScript
to do some tasks for HTML elements. You can use this class in CSS with a
specific class, write a period (.) character, followed by the name of the class
for selecting elements.
Syntax:
<tag class="ghf"> content </tag>
HTML Id Attribute
The id attribute is used to specify the unique ID for an element of the
HTML document. It allocates the unique identifier which is used by
the CSS and the JavaScript for performing certain tasks.
Syntax
<tag id="value">
HTML List Box
The list box is a graphical control element in the HTML document that
allows a user to select one or more options from the list of options.
Syntax:
<select Name="Name_of_list_box" Size="Number_of_options">
<option> List item 1 </option>
<option> List item 2 </option>
<option> List item 3 </option>
<option> List item N </option>
</select>
HTML Responsive
Responsive Web design
• Responsive web design is used to make your web page look appropriate,
good, and well placed on all devices (desktop, tablet, smartphone etc.)
• Responsive web design uses HTML and CSS to resize, hide, shrink,
enlarge, or move the content. It makes the content look good on any screen.
Syntax:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
HTML Entities
HTML character entities are used as a replacement of reserved
characters in HTML. You can also replace characters that are not
present on your keyboard by entities.
Attribute Description
<marquee width="100%" behavior="slide" bgcolor="pink">
This is an example of a slide marquee...
</marquee>
<marquee width="100%" behavior="alternate" bgcolor="pink">
This is an example of a alternate marquee...
</marquee>
Direction in HTML marquee
This is used to change the direction of scrolling text. Let's take an example of
marquee scrolling to the right. The direction can be left, right, up and down.
<marquee width="100%" direction="right">
This is an example of a right direction marquee...
</marquee>
<marquee width="100%" direction=“left">
This is an example of a right direction marquee...
</marquee>
HTML favicon
A favicon is a small file containing the one or more icons which are
used to represent the website or a blog.
It is also known as a tab icon, website icon, URL icon, or a bookmark
icon.
Syntax:
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
HTML Canvas Tag
The HTML canvas element provides HTML a bitmapped surface to work with.
It is used to draw graphics on the web page.
The <canvas> element is only a container for graphics, you must need a
scripting language to draw the graphics. The <canvas> element allows for
dynamic and scriptable rendering of 2D shapes and bitmap images.
Syntax:
<canvas id = "mycanvas" width ="200" height ="100"> </canvas>
HTML 5 Canvas Tag Example
<canvas id="myCanvas1" width="300" height="100" style="border:2px
solid;">
Your browser does not support the HTML5 canvas tag.
</canvas>
END OF SLIDE