Professional Documents
Culture Documents
What is HTML?
HTML is a markup language for describing web
documents (web pages).
HTML stands for Hyper Text Markup Language
A markup language is a set of markup tags
HTML documents are described by HTML tags
Each HTML tag describes different document
content
First developed by Tim Berners-Lee in 1990
HTML Example
<!DOCTYPE HTML>
<html>
<head>
<title>My First HTML Page</title>
</head>
<body>
<p>This is some text...</p>
</body>
</html>
</body>
</html>
HTML Basics with Examples
The alt attribute
specifies an alternative text to be used,
when an HTML element cannot be displayed.
HTML Elements
HTML documents are made up by
HTML elements.
HTML elements are written with a start tag, with
an end tag,
Start tag withContent
Element the content in between
End tag
<h1> First Heading </h1>
<p> First Para </p>
<h2> Second Heading </h2>
<br>
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
The content of the document......
</body>
</html>
HTML Tags
<a> Defines a hyperlink
<a href="https://www.mlrinstitutions.ac.in/">This is MLRIT website Link</a>
<h1 style="text-align:center">Centered Heading</h1>
<h1 style="font-family:verdana">This is a heading</h1>
<p style="font-family:courier">This is a paragraph.</p>
<h1 style="font-size:300%">This is a heading</h1>
<h1 style="color:blue;text-align:center">This is a
header</h1>
HTML Formatting Elements
Tag Description
<a href=“SampleImage.png">Image link</a>
HTML Links (2)
HTML Links - Colors
When you move the mouse over a link, two things will
normally happen:
◦ The mouse arrow will turn into a little hand
◦ The color of the link element will change
By default, a link will appear like this (in all browsers):
◦ An unvisited link is underlined and blue
◦ A visited link is underlined and purple
◦ An active link is underlined and red
HTML Links (3)
Example of Links
<style>
a:link {color:green; background-color:transparent; text-decoration:none}
a:visited {color:pink; background-color:transparent; text-decoration:none}
a:hover {color:red; background-color:transparent; text-decoration:underline}
a:active {color:yellow; background-color:transparent; text-decoration:underline}
</style>
<map name="planetmap">
<area shape="rect" coords="0,0,82,126" alt="Sun" href="sun.htm">
<area shape="circle" coords="90,58,3" alt="Mercury" href="mercur.htm">
<area shape="circle" coords="124,58,8" alt="Venus" href="venus.htm">
</map>
HTML Image attributes
<p>This is some text. <img src="smiley.gif" alt="Smiley face" align="left|right|
middle|top|bottom"> This is some text.</p
<img src="smiley.gif" alt="Smiley face" border="5">
<img src="smiley.gif" alt="Smiley" height="42" width="42">
<img src="smiley.gif" alt="Smiley face" hspace="20">
<img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap">
<img src="smiley.gif" alt="Smiley face" vspace="50">
<img src="smiley.gif" alt="Smiley" style="float:right;width:42px;height:42px;">
HTML Tables
<table style="width:100%">
<tr>
Tables are defined with
<td>Eve</td> the <table> tag.
<td>Jackson</td>
<td>94</td> Tables are divided into table
</tr> rows with the <tr> tag.
<tr>
<td>John</td> Table rows are divided into table
<td>Doe</td> data with the <td> tag.
<td>80</td>
</tr> A table row can also be divided
</table>
into table headings with
the <th> tag.
HTML Table attributes
Attribute Value Description
align left, center, right Specifies the alignment of a table according to surrounding
text
bgcolor rgb(x,x,x), colorname Specifies the background color for a table
border 1, 0 Specifies whether the table cells should have borders or
not
cellpaddin pixels Specifies the space between the cell wall and the cell
g content
cellspacin pixels Specifies the space between cells
g
frame void, above, below Specifies which parts of the outside borders that should be
hsides, lhs, rhs, vsides, box, visible
border
rules None, groups, rows Specifies which parts of the inside borders that should be
cols, all visible
width Pixels ,% Specifies the width of a table
HTML Table attributes
<table align=“left|right|center">
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
</table>
<table bgcolor="#00FF00">
<table border="1/0">
<table cellpadding="10">
<table cellspacing="10">
<table frame="box">
<table rules="rows">
<table width="400">
HTML Lists
HTML can have Unordered lists, Ordered lists, or Description
lists
An unordered list starts with the <ul> tag. Each list item starts with
<ul> Output
the <li> tag.
<li>Coffee</li> Coffee
<li>Tea</li> Tea
<li>Milk</li> Milk
</ul>
Style
<ul style="list-style-type:circle">
<ul style="list-style-type:disc">
<ul style="list-style-type:square">
<ul style="list-style-type:none">
HTML Ordered Lists
An ordered list starts with the <ol> tag. Each list item
starts with the <li> tag.
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
Type
<ol type=“1">
<ol type="A“>
<ol type="a“>
<ol type=“I“>
<ol type="i“>
HTML Ordered Lists attributes
Attribute Value Description
compact compact Specifies that the list should render smaller than normal
reversed (HTML reversed Specifies that the list order should be descending (9,8,7...)
5)
start number Specifies the start value of an ordered list
type 1, A, a, I, i Specifies the kind of marker to use in the list
<ol compact>
Reserved When present, it specifies that the list order should be descending (9,8,7...),
instead of ascending (1, 2, 3...).
<ol>
<ol reversed> <li value="100">Coffee</li>
<ol start=“100"> <li>Tea</li>
<li>Milk</li>
<li>Juice</li>
</ol>
HTML Description Lists
The <dl> tag defines a description list.
The <dt> tag defines the term (name), and the <dd> tag defines
the data (description).
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
Nested HTML Lists
List can be nested (lists inside lists).
<ul>
<li>Coffee</li>
<li>Tea
<ul>
<li>Black tea</li>
<li>Green tea</li>
</ul>
</li>
<li>Milk</li>
</ul>
<textarea> Element
<textarea name="message" rows="10" cols="30">
The cat was playing in the garden.
</textarea>
HTML Form Elements (2)
<button> element defines a clickable button
<button type="button" onclick="alert('Hello World!')">Click Me!</button>
<input type="password" name="firstname">
<input type=“submit" value=“Submit">
<input type="radio" name=“Gender" value="female">Female
<input type="checkbox" name="vehicle" value="Car“>car
<form>
<input type="range" name="points" min="0" max="10">
</form>
HTML Form: Input Attributes
The value Attribute
◦ The value attribute specifies the initial value for an input field
<input type="text" name="firstname" value="John">
Audio Element
<audio> Defines sound content
<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
</audio>
HTML5 Tags
<audio> attributes
controls Specifies that audio controls should be displayed (such as
a play/pause button etc)
<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg“>
</audio>
loop Specifies that the audio will start over again, every time it
is finished
<audio controls loop>
</audio>
HTML5 Tags
<audio> attributes
muted Specifies that the audio output should be muted
<audio controls muted>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
preload Specifies if and how the author thinks the audio should
be loaded when the page loads
<audio controls preload="none">
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg“>
</audio>
<bdo dir="ltr">
This text will go right-to-left.
</bdo>
<button type="submit" form="form1" value="Submit">Submit</button>
<button> attributes
formaction Specifies where to send the form-data when a form is
submitted. Only for type="submit"
<form action="demo_form.asp" method="get">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<button type="submit">Submit</button><br>
<button type="submit" formaction="demo_admin.asp">Submit as admin</button>
</form>
<button type="submit" formmethod="post" formaction="demo_post.asp">Submit using
POST</button>
HTML <cite> Tag
<p><cite>The Scream</cite> by Edward Munch. Painted in 1893.</p>
HTML Tags
HTML <code> Tag
<code>A piece of computer code</code>
HTML <div> Tag
◦ The <div> tag defines a division or a section in an HTML
document.
<div style="color:blue">
<h3>This is a heading</h3>
<p>This is a paragraph.</p>
</div>
◦ Border
<iframe src="demo_iframe.htm" style="border:5px/none dotted red"></iframe>
◦ Attribute Values
Value Description
left Align the iframe to the left
right Align the iframe to the right
middle Align the iframe in the middle
top Align the iframe at the top
bottom Align the iframe at the bottom
HTML iFrames Attributes (2)
<iFrame> : frameborder Attribute
◦ Syntax
<iframe src="/default.asp" width="200" height="200" frameborder="0">
</iframe>
◦ Attribute Values
Value Description
1 Default. Border on
0 Border off
HTML iFrames Attributes (3)
Width and Height
<iframe src=“default.asp" width="200" height="200”></iframe>
Scrolling
<iframe src=“default.asp" width="200" height="200" scrolling="yes">
</iframe>
HTML <head> Element
The <head> element is a container for metadata
(data about data).
HTML metadata is data about the HTML document.
Metadata is not displayed.
Metadata typically define document title, styles, links,
scripts, and other information.
Inthe HTML5 standard, the <html> tag, the <body> tag,
and the <head> tag can be omitted.
HTML <title> Element
The <title> element defines the title of the document.
The <title> element is required in all HTML/XHTML
documents.
The <title> element:
◦ defines a title in the browser tab
◦ provides a title for the page when it is added to
favorites <!DOCTYPE html>
◦ displays a title for
<html> the page in search engine results
<title>Page Title</title>
<body>
The content of the document......
</body>
</html>
HTML <Style> Element
The <style> element is used to define style
information for an HTML document.
Inside the <style> element you specify how HTML
elements should render in a browser:
<style>
body {background-color:yellow;}
p {color:blue;}
</style>
HTML <link> Element
The <link> element defines the page relationship
to an external resource.
The <link> element is most often used to link to
style sheets
<link rel="stylesheet" href="mystyle.css">
HTML <script> Element
Inline Elements:
◦ An inline element does not start on a new line and only
takes up as much width as necessary.
<span>
<a>
<img>
The <div> Element
◦ The <div> element is a block-level element that is
often used as a container for other HTML elements.
◦ The <div> element has no required attributes,
but style and class are common.
HTML Block and Inline Elements (3)
◦ Example of <div>
<div style="background-color:black; color:white; padding:20px;">
<h2>London</h2>
<p>London is the capital city of England. It is the most populous city in the United
Kingdom, with a metropolitan area of over 13 million inhabitants.</p>
</div>
Loop
<video controls loop>
Muted
<video controls muted>
Poster
<video controls poster="/images/w3html5.gif">
preload
<video controls preload="none">
HTML5 Audio (HTML5 Element)
To play an audio file in HTML, use
the <audio> element:
<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
</audio>
The getElementById() method returns the element that has the ID attribute with the
specified value.
1.Creating Canvas Element (getElementById)
2.Create a Drawing Object (getContext- has methods and
properties for drawing)
3.Draw on the Canvas
HTML5 Canvas(2)
Canvas Coordinates
◦ The HTML canvas is a two-dimensional grid.
◦ The upper-left corner of the canvas has the coordinates
(0,0)
HTML5 Canvas(3)
Draw a Line
Following methods are used to draw a line
◦ moveTo(x,y) - defines the starting point of the line
◦ lineTo(x,y) - defines the ending point of the line
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
ctx.moveTo(0,0);
ctx.lineTo(200,100);
ctx.stroke();
HTML5 Canvas(4)
HTML draggable Attribute
◦ The draggable attribute specifies whether an element is draggable
or not.
HTML Global Attributes
HTML hidden Attribute
<p hidden>This paragraph should be hidden.</p>
HTML translate Attribute
<p translate="no">Don't translate this!</p>
<p>This can be translated to any language.</p>
HTML Global Attributes
HTML lang Attribute
◦ The lang attribute specifies the language of the
element's content.
<p lang="fr">Ceci est un paragraphe.</p>
HTML spellcheck Attribute
◦ The spellcheck attribute specifies whether the element is to have
its spelling and grammar checked or not
◦ Textarea, editable area are only checked
<p contenteditable="true" spellcheck="true">This is a paragraph.</p>
Thank You