HTML, CSS & Javascript Notes
HTML, CSS & Javascript Notes
● Introduction to HTML 5
● How HTML 5 code gets rendered on the page
● Required tools to learn HTML 5
● HTML 5 text formatting tags
● HTML 5 list elements
● HTML 5 attributes
● HTML 5 Link elements
● HTML 5 image element
● HTML 5 table element
● HTML 5 semantic elements
● HTML 5 multimedia elements (like audio, video, iframe)
● HTML 5 entities
● HTML 5 accessibilities
● HTML 5 tools
● HTML 5 DOM
● HTML 5 W3C validation
● Styling Module
● Color Module
● Text Module
● Fonts Module
● Selectors
● Pseudo Classes
● Generated Contents
● Specificity
● Values & Units
● List Styles
● Box Model
● Background Module
● Gradients
● Display Module
● Positioning Module
● Filters Module
● Clipping & Masking
● Blending Modes
● Shapes Module
● Table Layout
● Transformation
● Transition & Animations (Keyframes)
● Media Queries
● Newly Introduced CSS 3 concepts
● Flexbox Layout
1|Page
What you are going to learn in JavaScript (EcmaScript) ?
● Introduction to JavaScript
● Introduction to programming
● About JavaScript language behaviour
● Keywords and Reserve words
● Variable or Identifier and its naming convention
● Data types
● Values & its type in JavaScript
● Operand, Operator, Expression, Instruction and Statement
● Comments
● Types of Operators (Unary, Binary & Ternary)
● Conditional statements
● Control statements
● Difference between undefined & undeclare
● Type of errors in JavaScript
● Scope
● Function and its types
● How scope works for a variable and a function ?
● How JavaScript code gets executed ?
● Execution context, Call stack & Heap
● Scope and Function Expression
● Hoisting and Shadowing
● var, let and const
● Coercion (Explicit & Implicit)
● Equality
● Closure
● Array and its methods
● Object
● Call by value & Call by reference
● String and its methods
● Template Literals
● Number and its representations (Binary, Octal, Decimal & HexaDec)
● Prototypes
● Object Oriented Principles (OOP) in JavaScript
● Rest and Spread
● Destructuring (Array & Object)
● Symbols
● Iterators & Generators
● Regular Expression
● Promise
● async and await
● Event Queue and Event Loop
● New utility methods or Higher order functions for Array
● JavaScript latest features
● Modular JavaScript
● Document Object Model (DOM)
● Browser Object Model (BOM)
● Security
2|Page
html => hypertext markup language
=> data presentation
=> UI designing (sign up, login, registration, search form…)
= static webpages
JS => JavaScript
=> its back-end for html/css (Front-end)
=> it provides logical support or client validations
advJava/spring/asp.net/python/php/nodejs back-end dev
4|Page
2. Your computer contacts anetwork of servers calledDomain Name System (DNS)servers. These
act like phonebooks; they tell your computerthe IP address associated withthe requested
domain name.An IP address is a numberof up to 12 digits separatedby periods / full stops.
Everydevice connected to the webhas a unique IP address; it islike the phone number for
thatcomputer.
3. The unique number that theDNS server returns to yourcomputer allows your -browserto
contact the web serverthat hosts the website yourequested. A web server is acomputer that is
constantlyconnected to the web, and is setup specially to send web pagesto users.
4. The web server then sends thepage you requested back to yourweb browser.
Server
A server is a computer or system that provides resources, data, services, or programs to other
machines, known as clients, over a network/inet.
In theory, whenever computers share resources with client machines, they are considered servers.
a server stores all the data associated with the websites that are hosted by it and shares that info
with all computers and mobile devices (like yours) that need to access them.
Client
A client is a electronic device that connects to and uses the resources of a remote computer, or
server.
Client maybe a desktop or a laptop or a tablet or a mobile phone or a TV etc.
The device which is used by the user is called as “Client”.
User
The person who is working on/operating client machine is known as User or end-user.
5|Page
Client:
It is a machine or device (desktop or laptop or tablet or mobile phone or TV etc), which can access
the data from server machine.
The device which is used by the user is called as “Client”, person who is working on client machine is
known asUser.
Email: Electronic mail services. It is a free service to communicate with other internet users. Email is
invented by Shabeer Bhatia. Sabeer Bhatia is an Indian entrepreneur who founded the webmail
company Hotmail.com.
SMTP: Simple Mail Transfer Protocol. It takes care of delivering emails from one server to another.
MIME: Multipurpose Internet Mail Extensions. It exchanges different kinds of data.
Blog: It is daily updating website or webpage. Every post displayed in reverse chronological order.
Forum: It is an online discussion website to exchange resources each other.
Http: It is a transfer protocol to exchange hypertext documents in the world wide web.
Http(s): Secured transfer protocol to exchange hypertext documents with the help of
SSL(ciphertext).
Ciphertext is encrypted text. Plaintext is what you have before encryption, and ciphertext is the
encrypted result. The term cipher is sometimes used as a synonym for ciphertext, but it more
properly means the method of encryption rather than the result.
Static webpage: A user unable to interact directly with these webpages. Eg: HTML, CSS
Dynamic webpage: End-user can able to interact directly with these webpages. Eg: HTML, CSS
&Javascript
6|Page
Collection of webpages or web documents are called web application(website). These are classified
into two types:
STATIC WEB APPS:The applications which can’t able to handle business logic are known as static
web apps.Static apps will contain only client layer.We can develop static web applications using
HTML. To provide look and feel to these static pages we can use CSS. To handle client layer business
logic we ca use Javascript.We can’t able to maintain end user interaction(state) using static web
apps.
DYNAMIC WEB APPS:The applications which can able to handle business logic are known as
dynamic web apps.These type of apps contains at least 2 layers client and business. If we need to
store client data then these application contains data layer too.We can develop client layer using
HTML, CSS &javascript and business layer using any one of the server programming language like
.NET, JAVA/J2EE & PHP etc...We can store end user data using any database like mongo db, MS-SQL,
MySql, Oracle etc.
What is HTML?
It is specially designed hypertext for web browsers, with meaningful tags or elements in simple
English language.
HTML Versions
From W3C organization there are fallowing versions released.
Version Specification Release Date
1.0 N/A (HTML 1.0) 1-Jan-1994
2.0 HTML 2.0 24-Nov-1995
3.2 W3C: HTML 3.2 14-Jan-1997
4.0 W3C: HTML 4.0 24-Apr-1998
4.1 W3C: HTML 4.1 24-Dec-1999
5.0 WHATWG 28-Oct-2014
(Adv Markup Language For Mobiles)
5.1 W3C: HTML 5.1 -Nov-2016
(Adv Markup Language For Small Electronic Devices)
5.2 W3C: HTML 5.2 14-Dec-2017
HTML Intro
1. HTML wasdeveloped by “Tim-Berners-Lee”, released in 1994 and maintained by W3C Org.
3. Hypertext” means the text that can be transferred from internet server to internet client.
"Markup Language" means which syntax will be in the form of tags or you simply "markup" a
text document with tags that tell a Web browser how to structure it to display.
7|Page
4. Technically, HTML is not a programming language, but rather a markup language.
5. HTML is used to design "static web pages", means HTML is used to create elements (such as
headings, paragraphs, icons, menus, logos, images, textboxes, button etc) in the web pages.
static webpage means, that pages always showing same information.
7. HTML is “client side tech”. That means the html code executes on the client browser but not
in server.
web tech:
which sw are supporting to design web pages or providing API to dev web coding those sw are
called as web tech.
>client side tech ex: html/css, js, jquery, BS ...
used for static web pages.
bw rec source code & trans after execution then produced the
output.
>server side tech ex: servlet, jsp, asp.net, php, cgi, nodejs, cold fusion ...
dynamic web pages.
code trans, execute with in server only, and produced output, this
output sent to client machine.
8. HTML is supported by all the browsers such as Google Chrome, Mozilla Firefox, Microsoft
Internet Explorer, Safari, Opera and other browsers.
9. HTML is used in all real time web sites today; html is the only language available in world for
designing Webpages.
2. HTML is an interpreter-based language. That means the HTML code will be converted
into machine language in +. Browser interprets HTML code.
Translators:converting high level code (human) into machine level code (MP/OS) is called as
translation. who performs this operation those called as translators.
types: >compiler ex: c, cpp,...
8|Page
>interpreter ex: html, js, oracle,...
>assembler
3. for working html no need installs any software, and browser is responsible for executing &
producing output of html programs.
5. HTML is not a case sensitive language that means you can write the html code in either
upper case or lower case.
notepad, editplus, notepad++, textpad, sublime, ms vs, word, atom, coffee, ...
save that program with any name (.html or .htm) and anywhere in system.
but filename must be single word (space is not allowed).
> execution:
1st Approch:goto file location, then dbl click on file
2nd Approch:goto file location, then right click on file and click on open then select browser
3rd Approch:open any browser, then goto address bar and type filename with address.
d:\siva\test.html e:\test.html
Tag:
A tag is a keyword, enclosed within "<" and ">" in HTML language.
It is special kind of text placed between left angular brace and right angular
brace(<tag_name>).
Tag is predefined program, program is instructions / command to browser.
Tag is used to display some specific output in the web page.
browser was not identified the tag; it shows blank page or it prints as text.
tags also represented as elements.
tag has some attributes(properties), those are used to change look & feel (components or
output).
types of tags:
9|Page
opening tag specifies starting point of operation/output, closing tag specifies ending point of
operation/output.
Syn: <tagname>something</tagname>
</tagname>
ex: <html> ... </html>
<head> ... </head>
<body> … </body>
<script> ... </script>
<style> ... </style>
<p> … </p>
note: paired tags also called as body
body-full tags
>unpaired tags
contains only open tag.
VOID => ITS not RETURNING ANY VALUE
Syn: <tagname> or <tagname/>
ex: <br/> <img/><input/>
<hr>
<link>
note: Unpaired tags also called as body
body-less tags
Structure of HTML
as per W3C we have to follow the following structure to design web pages (but it’s not comp).
<!DOCTYPE html>
<html> web
web page/document designing starts here
<head>
-> non-content
content sec(non
sec(non-result)
->> settings/internal info about page
-> 1st executed sec
Ex: title tag, link tag, style tag, script tag, meta tag
</head>
<body>
->> content sec(result)
->it
>it contains page designing
-> 2nd executed sec
Ex: form, h1, h2, h3, h4, h5, h6, p, div, table, img, a, button, audio, video, iframe,
etc…
</body>
</html> web
web page/document designing ends here
versioning section
this is providing information to browser which version we are using in webpage/program. So,
browser is interpreting code and producing output as per given specification.
Syn:
10 | P a g e
<!DOCTYPE htmlversion-url>
HTML4.0:
<!DOCTYPE html public "-//W3C//DTD HTML 4.0//EN" "http://www.w3c.org/TR/html4/strict.dtd">
XHTML:
<!DOCTYPE html public "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Html+xml =>xhtml
HTML5:
<!DOCTYPE html> current version
html tag
the <html> tag represents starting and ending of html program. html tag contains two child/sub
tags those are head tag and body tag.
head tag
head tag represents non-content section (means not output) of the web page.
this information doesn't appear on webpage/in browser (it's called as non-content), but it's used
internally by the browser.
this tag is used to set icons, title, to provide some meta data (info about web app), css settings, java
scripting etc...
head tag contains some child/sub tags, those are
Syn:
<head>
<link>
<title></title>
<meta>
<style></style>
<script></script>
...
</head>
body tag
body tag represents content information (means output) of the web page.
this information appears on webpage/in browser (it’s called as content).
this tag is used to design UI or to display output.
body tag contains so many child/sub tags.
some of tags:
<body>
<form>
11 | P a g e
<h1>
<h2>
<p>
<div>
<input>
<a>
<audio>
<video>
<iframe> etc...
</body>
comment lines
comment lines are to provide some description about of our program.
Syn:
<!-- comments -->
comments are not executed by browser.
heading tags
these tags are used to print data/text in heading format.
html providing 6 heading tags, those are h1, h2, h3, h4, h5, h6.
These 6 tags are used to display headings in different sizes.
six tags are paired tags and block level elements.
Syn:
<h1> text </h1>
<h2> text </h2>
<h3> text </h3>
<h4> text </h4>
<h5> text </h5>
<h6> text </h6>
Note: inside body section we can repeat any tag and no.of times.
p tag
> p stands for paragraph.
> this tag is used to display/print more lines of text (paragraph)
> its paired tag and block level.
> browser display an empty line(gap) between paragraphs
Syn:
<p> text or info </p>
Note:
>browser/html doesn't accept more than one space (space bar & tab key), means while designing of
program we given more space but browser prints only one space.
12 | P a g e
>browser/html doesn't accepts enter key (line breaking), means while designing of program we use
enter key but browser prints data without breaking line.
br tag
Html entities
Syn: &entity;
Label tag
>label tag used for displaying prompting text.
>its paired tag, inline tag
Syn: <label> text </label>
Span tag
>span tag used for small textual data, like as error message, mandatory specification.
> in continuity of text, if we want to highlight couple of word or letters,
we use span tag
>its paired tag, inline tag
Syn: <span> text </span>
pre tag
> pre stands for pre-formatting (alignment)
> pre tag is used to print data/text, how we typed in same format
> pre is paired tag, block level
Syn:
<pre> text </pre>
formatting tags
13 | P a g e
Ex: Apple apple 4568 apple H20 a2
b tag or strong
> b stands for bold
> b tag used to print text in bold format
>both are paired tags & inline tags
Syn:
<b> text </b>
<strong> text </strong>
u tag
> u stands for underline
> u tag used to print text with underline (draws a line base of text)
> u is paired tag
Syn:
<u> text </u>
strikeout tag
> strikeout tag used to print text with line (draws a line middle of text)
>strikeout is paired tag
Syn:
<strike> text </strike>
superscript tag
>this tag used to display text top of upper line
> superscript is paired tag
Syn:
<sup> text </sup>
subscript tag
>this tag used to display text bottom of baseline
> subscript is paired tag
Syn:
<sub> text </sub>
I or em tag
>i stand for italic (inclined)
>i tag used to print text with little banding
>i is paired
Syn:
<i> text </i>
<em> text </em>
14 | P a g e
All 6 tags are paired tags &inline tags
title tag
this tag used to set the title for a webpage, means every webpage
they have individual title.
its paired tag.
<title> is the sub tag of <head> tag.
Web site => 10 web pages =>Title 10 times
Syn:
<title>text</title>
Note: one web page/one title
Link tag
Link tag used to set the icon/logo for a webpage.
Un-paired tag.
<link> is the sub tag of <head> tag.
Syn: <link rel=”stylesheet” href=”filename”/>
Relative
Hyper reference =>.jpg .bmp .png .jfif .gif .tif .ico
Preferable image size:
18px X 18px
20X20px
30X30px
40X40px
Attributes
> attribute is a special feature/setting
setting/property of a tag.
> attributes are used to change the default look/feel of data(elements).
> every tag they have attributes
Syn:
<tagname attribute="parameter" attribute=’parameter’ ...
...> Html
Width=”100px” height=200px
Note:
parameter means the value of attribute.
Parameter should enclosed within “ “ or ‘ ‘ or without quotes.
Every attribute must be separated by a space
types:
as per html4 we have 3types of attributes, those are
>global attributes (core)
Ex: id, name, class, style, align, width, height, title etc…
>specific attributes (personal)
Ex: rel, href, src, colspan, rowspan, action, alt etc…
>event attributes (dynamic)
Ex: onclick, onload, onfocus, onblur, onchange, onsubmit, onkeypress,
15 | P a g e
Oncopy, onpaste, oncut, onchange, ondblclick, oncontextmenu, onmousemove,
onmouseover, onmouseexit etc…
>optional attribute <== html5
Ex: lang, type, method etc…
global attributes:
these attributes are common for most of tags (99% of tags)
those attributes are:
class, id, name, style, align etc...
ex:
<h1 class="" id="" name="a" style="" ...>
<p id="" class="" name="b" style="" ...>
<pre class="" id="" name="c" style="" ...>
specific attributes:
these attributes are specific to some tags/elements only (not common).
those attributes are:
src, href, rel, target, colspan, rowspan, alt, placeholder, poster, loop, etc...
ex:
<a href="url" ... >
<imgsrc="" ...>
<audio controls>
event attributes:
these attributes are used to some logical operations.
logical operations we can perform by using JavaScript, these also called dynamic attribute.
attributes are:
onclick, oninput, onfocus, onexit, onload, onchange,onblur, ....
ex:
<button onclick="js code/fun1">
<body onload="js code">
optional attributes:
these attributes are not comp to specify/to use.
these type attributes are supported since html5.0.
those attributes are:
lang, type, method ...
ex:
<style type="text/css" ...>
<script type="text/javascirpt" ...>
<link type="image/jpg" ...>
<form method="get" ...>
categories of attributes:
html attributes <tag attribute="value">
css attributes <tag style="css-attribute:value; css-attribute:value;...">
16 | P a g e
CS S change look/feel of html elements
Css provide only styles but not tags
Style is group of attribute/properties
2ndApproch (internal):
Html tags and css styles are designed in the same program, but not in same line.
Internal css should be implements in Style tag, style tag must be sub tag head tag.
<style>
h1{
attribute:value;
attribute:value;
…
}
Selector{
attribute:value;
attribute:value;
…
}
…….
</style>
3rdApproch (external)
Css styles are designed in separate file and should be save with “.css”, and html code saved with
“.html”
Use link tag for mapping css file to html file
Syn: <link rel=”stylesheet” href=”filename.css”/>
note:
css attributes we can't use in place of html attributes.
html attributes we can't in place of css attributes.
“Id” attribute we are using while writing javascript code.
“Name” attribute we are using while writing server-side code. (servlet, jsp, asp, php, noedjs)
images
> "img" tag is used to display images on webpage.
> in one webpages we can display any no.of images and any type of images.
> it is strongly recommended to place all images in side root folder or create
sub folder with name images in root folder
>its un-paired tag, and its inline element
Syn:
<img attributes/>
17 | P a g e
.jfif .svg.jpg .bmp .gif .tif .png .webp
attributes:
src => to specify which img you want to display
width => width of image (pixel)
height => height of image (pixel)
title => it is used to specify tool tip. ((whenever
whenever mouse pointer comes on top of image)
alt => alternative text, if image not loaded in webpage/not display, we want to display text message
to user it called as alt
+
global attributes
opacity: 0.5;
filter: blur(5px);
brightness(125%)
contrast(135%)
grayscale(100%)
invert(100%)
hue-rotate(180deg)
saturate(8)
sepia(100%)
drop-shadow(8px
shadow(8px 8px 10px green)
hyperlinks
> a stand for "anchor”
>"a" tag is used to create hyperlink, hyperlinks are used to move from one webpage to another
webpage.
>whenever user clicks on the hyperlink, it moves to the specified page.
> destination page sometime within same application or other application.
>web application basically contains links to other pages, so it's very commonly used tag.
> by default, every browser provides built
built-in style for each hyperlink,
18 | P a g e
Syn:
attributes:
href : hyper reference, used to specify the ad address of webpage or web site, i.e whenever user clicks
on this link, which page you want to open
url may be html page, server
server-side
side file, image, audio file, video, pdf file, documents
etc...
href=”url”
“https://www.abc.com/login.aspx
https://www.abc.com/login.aspx”
“” self-calling
calling
“.” home page of web site/home dir of web application
“#id” it creates book marks (moving within same page)
html colors
html supports 3types of patterns, those are
> named colors
> RGB colors
> Hexadecimal colors
named colors:
>it supports to write direct colorname
>we have some limited colors
ex: white, black, red, green etc...
> color names are not case-sen
RGB colors:
>RGB model specifies that the composition of 3 basic colors (Red, Green, Blue)
>RGB produces 16millions colors.
Syn: rgb(red,green,blue)
red => 0 - 255
green => 0 - 255
blue => 0 – 255
ex: rgb(10, 45, 201) 401%255 146
19 | P a g e
Hexadecimal number colors:
>Hexadecimal model is the shortcut for rgb model
>Hexadecimal system ranges from 0 - 15
0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f
Syn: #RRGGBB 1,2 red 3,4 green 5,6 blue
ex: #1a4b68
#RGB
ex: #3d7
Gradient colors
background: #FC466B; /* fallback for old browsers */
background: -webkit-linear-gradient(to bottom, #3F5EFB, #FC466B); Chrome 10-25,
Safari 5.1-6
background: linear-gradient(to bottom, #3F5EFB, #FC466B); W3C, IE 10+/ Edge, Firefox
16+, Chrome 26+, Opera 12+, Safari 7+
linear-gradient(direction, color1,color2,…color-n)
dir: to left (r=>l)
to right (l=>r)
to top (b=>t)
to bottom (t=>b)
Note: while applying gradient colors we have to use “background” property in place of
“background-color”.
20 | P a g e
working with list tags
these tags are used to display data/info in points wise.
html supports three types of list, those are
Ordered list numbering
Unorderedlist bulleting
ol tag
>ol stands for "Ordered List".
>it is used to display the text(names, colors, team names, course name...) with numbering.
>it supports 5types numbering, those are 1, A, a, i, I. by default it displaying in number.
>by using "ol" tag we can create ordered list
>ol is paired tag & block level element
li tag
> li stands for "list item"
> li is sub tag of ol tag
> li tag is used to print text/data in points wise
> li is paired tag & block level element
Syn:
<ol attributes>
<li> text </li>
<li> text </li>
<li> text </li>
...
</ol>
ol attributes:
type : which type numbering to display (Default is 1)
start : from where u want to start numbering (default is 1)
reversed : to displaying numbers in desc order
li attributes:
value : used for restarting numbering with specified value
ul tag
>ul stands for "Un-Ordered List".
>it is used to display the list of items(names, colors, team names, course name...) with bulleting.
>it supports 3types bulleting, those are dot, circle, square. by default, is dot.
>by using "ul" tag we can create un-ordered list items
> ul is paired tag
>"li" tag used for creating list items
Syn:
<ul type="dot/circle/square">
<li> text </li>
<li> text </li>
21 | P a g e
<li> text </li>
...
</ul>
dl tag
>dl stands for Definition list (since html5 description list)
>dl tag used for to display definitions/full forms (collection of definitions)
>its paired tag
> "dt" and "dd" are sub tags of "dl" tag
> "dt" stands for definition title, "dd" stands for definition data.
> dt & dd are paired
Syn:
<dl>
<dt>title/word</dt>
<dd>information</dd>
<dt>title/word</dt>
<dd>information</dd>
<dt>title/word</dt>
<dd>information</dd>
...
</dl>
fieldset tag
> this tag used for drawing a line/border around elements/tags.
> its paired tag and block level
> we can draw any no.of borders
Syn:<fieldset attributes>
<legend>text</legend>
Sub elements
</fieldtset>
attributes:
align : align of elements, it supports 3 alignments center, left, right
left is default align
border : style of line, thickness of line, color of line
width : width of box (size in % )
legend tag
>legend tag used for set title/heading for fieldset
>legend is sub tag of fieldset tag
>its paired tag
Syn:<legend attributes>Heading</legend>
attributes:
align :align of elements, it supports 3 alignments center, left, right
left is default align
22 | P a g e
color :
div tag
>div is a container, means its grouping elements/controls/components of html.
>inside div tag we can place any content like normal text or images.
>div tag is used to divide web page as no.of subpages/parts, each part is rep as div.
>for better maintained, effective design of web page and simplifying css code.
>its paired tag, and block level element
Syn: <div attributes>
contents
</div>
>one webpage may contains any no.of div tags.
display:flex; <== it displaying all elements side-by-side row wise or column wise
flex-wrap:wrap; <== it align element to next line
flex-direction <== it used to specifiy direction (order) of flex elements
flex-direction:row|row-reverse|column|cloumn-reverse;
flex-flow <== it combination of felx-wrap & flex-direction attributes.
flex-flow: direction wrap;
Note: its applicable on nested tags, means outer tag only we can apply grid
table tag
>table tag is used to display the data in form rows & cols in the web page.
> a table is a collection of rows, each row is collection of cells/col/field.
> a table is represented as <table> tag, a row represented as <tr> tag, a colheading is represented as
<th> tag, data rep as <td> tag.
> table heading is represented as <caption> tag.
><thead> tag is rep of table head part, <tbody> tag is rep of table bodypart and <tfoot> tag Is rep of
table footer part.
table it just comb rows & cols
caption main heading of table
23 | P a g e
tr table row, used to draw a row
th table heading (col heading)
td table data (col data)
thead table head section
tbody table body section
tfoot table footer section
Syn:
<table>
<tr>
<th>heading</th> <th>heading</th>
</tr>
<tr>
<td>data</td> <td>data</td>
</tr>
...
</table>
Note:
<th> and <td> are sub tags of <tr>
<tr> is sub tag of <table>
table attributes:
border : border of table (0 means no border, 1-n border req)
align : alignment of table
width : width of table (%)
...
th& td attributes:
colspan : specifies the no.of columns to merge/expend
rowspan : specifies the no.of rows to merge/expend
...
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<h1>Hypertext Markup Language</h1>
<h2>Hypertext Markup Language</h2>
<h3>Hypertext Markup Language</h3>
<h4>Hypertext Markup Language</h4>
<h5>Hypertext Markup Language</h5>
24 | P a g e
<h6>Hypertext Markup Language</h6>
<h1>Cascading Style Sheets</h1>
<h3>JavaScript</h3>
</body>
</html>
</body>
</html>
25 | P a g e
« » <br>
±120 <br>
¾ <bR>
10÷3<br>
ß
</body>
</html>
</head>
<body>
<strong>HTML</strong>
<b>CSS</b>
<br>
<em>JavaScript</em> <i>BootStrap</i> <br>
<u>Ajax</u>
<strike>AngularJS</strike> <bR>
H<sub>2</sub>SO<sub>4</sub> <br>
</body>
</html>
26 | P a g e
<!-- EXAMPLE on label & span tags -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>My 2nd Webpage</title>
<link rel="icon" href="logo1.png"/>
</head>
<body>
<label>enter firstname</label>
<label>enter lastname</label>
<br>
<span>hello</span>
<span>invalid email id</span>
<br>
<p>EditPlus is <span style="background:yellow;">not free</span> software. You may use
this software for evaluation purposes without charge for a period of <span
style="background:yellow;">30 days</span>. If you use this software after the 30 day evaluation
period, you <span style="background:yellow;">must buy the license</span>.</p>
<br>
<h3>Login Form</h3>
<label>Username</label> <span style="color:red;">*</span> <br>
<input type="text"/> <br>
<label>Password</label> <span style="color:red;">*</span> <br>
<input type="password"/> <br>
<button>Log In</button>
</body>
</html>
27 | P a g e
<!-- EXAMPLE on img tag -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ex8</title>
<link rel="icon" href="logo.png"/>
</head>
<body>
<h3>demo on displaying images</h3>
<img src="e:/html6pm/images/tree.jpg"/>
<!-- <img src="https://www.sitename.com/images/tree.jpg"/> -->
<img src="images/car.jpg" width="500px" height="260px"/>
<br>
<img src="images/pic.gif" width="100%" height="400px"/>
<br>
<img src="images/water.jpg" title="Waterfalls, Hyderabad"/>
<br>
<img src="images/flower.pn" alt="image not diasplayed try again"/>
</body>
</html>
</body>
</html>
28 | P a g e
<!-- EXAMPLE on a tag -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ex10</title>
<link rel="icon" href="logo1.png"/>
</head>
<body>
<h3>demo on hyperlinks</h3>
<a href="files/Application.pdf" >Click here to Apply Job</a>
<br>
<a href="files/HTML YS-1.docx">html document</a>
<br>
<a href="files/npp.8.4.2.Installer.exe">download Notepad++</a>
<br>
<a href="files/[iSongs.info] 01 - Toofan.mp3" target="_blank">play audio</a>
<br>
<a href="files/Children _ Infobells.mp4">play video</a>
<br>
<a href="images/car.jpg">
<img src="images/car.jpg" width="200px" height="100px"/>
</a>
</body>
</html>
<!-- CSS
==> cascading style sheets 3.0
==> developed & maint by W3C org
==> used to change the look & feel of webpage
==> re-defining html tag/ overriding of html tags
inline css:
html tag & css styles are defined with in the same line
used to define presonal styles for html tags
Syn:
<tag style="property:value;property:value;...">
-->
29 | P a g e
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ex11</title>
<link rel="icon" href="logo1.png"/>
</head>
<body>
<h3>demo on inline styles</h3>
<h1 style="color:red;">HTML</h1>
<h1 style="color:red;">CSS</h1>
<h1 style="color:red;">JavaScript</h1>
<h1 style="color:blue;">BootStrap</h1>
<h1 style="color:green;">Angular</h1>
</body>
</html>
<!--
internal
html tags & css styles are defined with in the same program/page, but not in same line.
internal styles should be define in the <style> tag.
style is paired tag & it must be sub tag of <head> tag
used to define global styles for webpage
Syn:
<style>
tag-name{
property:value;
property:value;
...
}
tag-name{
property:value;
property:value;
...
}
</style>
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ex12</title>
<link rel="icon" href="logo1.png"/>
<style>
h1{
color:red;
}
label{
color:blue;
30 | P a g e
}
</style>
</head>
<body>
<h3>demo on internal styles</h3>
<h1>HTML</h1>
<h1>CSS</h1>
<h1>JavaScript</h1>
<label>Username</label> <br>
<label>Password</label>
</body>
</html>
<!--
external css:
html tags & css styles are defined in seperate files
used to define global styles for application
Syn: tag-name{
property:value;
property:value;
...
}
tag-name{
property:value;
property:value;
...
}
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ex13</title>
<link rel="icon" href="logo1.png"/>
<link rel="stylesheet" href="mystyles.css"/> <!-- linking done -->
</head>
<body>
<h3>demo on internal styles</h3>
<h1>HTML</h1>
<h1>CSS</h1>
<h1>JavaScript</h1>
<h2>Angular</h2>
<h2>ReactJS</h2>
</body>
</html>
31 | P a g e
<!-- example on css models -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ex13</title>
<link rel="icon" href="logo1.png"/>
<link rel="stylesheet" href="mystyles.css"/> <!-- linking done -->
<style>
h3{
color:hotpink;
}
</style>
</head>
<body>
<h3>demo on internal styles</h3>
<h1>HTML</h1>
<h1>CSS</h1>
<h1>JavaScript</h1>
<h1 style="color:cyan;">Ajax</h1>
<h2>Angular</h2>
<h2 style="color:blue;">ReactJS</h2>
<h2>NodeJS</h2>
<h3>BottStrap</h3>
<h3>JQuery</h3>
</body>
</html>
background-color => css prop, used to change background color of html elements
Syn: background-color:color-spe;
color specifications:
> named color
writing color name directly
ex: red green yellow
32 | P a g e
Syn: rgb(red,green,blue)
every color range should be bw 0 to 255
ex: rgb(12,45,89)
</body>
</html>
linear-gradient => applying multi colors in linear mode means either horizontally or vertically
Syn: linear-gradient(direction, color1, color2, ...)
direction => to left, to right, to top, to bottom
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ex16</title>
<link rel="icon" href="logo1.png"/>
</head>
<body style="background:linear-gradient(to left, blue 40%, #ff00ff 60%);">
<h3>demo on gradient colors</h3>
33 | P a g e
<p style="background:linear-gradient(to right, #00cc00,#ffff00);">You may copy the
evaluation version of this software and documentation as you wish, and give exact copies of the
original evaluation version to anyone, and distribute the evaluation version of the software and
documentation in its unmodified form via electronic means. But you should not charge or
requesting donations for any such copies however made and from distributing the software and/or
documentation with other products without the author's written permission.</p>
</body>
</html>
34 | P a g e
<!-- example on css borders
border => used to draw a line around html elements
Syn: border:thick style color;
</body>
</html>
35 | P a g e
<!-- example on css shadows
box-shadow => used to apply shadow for html elements, but shapes only
Syn: box-shadow:Xpx Ypx color;
text-shadow => used to apply shadow for html elements, but text/data only
Syn: text-shadow:Xpx Ypx color;
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ex19</title>
<link rel="icon" href="logo1.png"/>
</head>
<body>
<p style="box-shadow:3px 3px; background:cyan;">You may copy the evaluation version
of this software and documentation as you wish, and give exact copies of the original evaluation
version to anyone, and distribute the evaluation version of the software and documentation in its
unmodified form via electronic means.</p>
36 | P a g e
</style>
</head>
<body>
<fieldset>
<h1>HTML</h1>
<h1>CSS</h1>
<h2>JavaScript</h2>
</fieldset>
<br>
<fieldset style="border:10px outset red; width:1000px;" align="center">
<legend>My Photos</legend>
<img src="images/pic1.jpg"/>
<img src="images/pic2.jpg"/>
<img src="images/pic3.jpg"/>
<img src="images/pic4.jpg"/>
<img src="images/pic5.jpg"/>
<img src="images/flower.png"/>
</fieldset>
</body>
</html>
<!--
html list tags
> ol
> ul
37 | P a g e
-->
<!-- example on list tags -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ex21</title>
<link rel="icon" href="logo1.png"/>
</head>
<body>
<h3>demo on Ordered List</h3>
<h4>How do I make a payment using Flipkart's credit card EMI option?</h4>
<ol>
<li>Choose your credit-card issuing bank you wish to pay from</li>
<li>Select the EMI plan of your preference</li>
<li>Enter your credit card details</li>
<li>Click 'Save and Pay'</li>
</ol>
<hr> <!-- it draws a line horizontally (left to right edge) -->
38 | P a g e
<!--ul ==> unordered list
==> used to display data in points format with bulletting style
bullet styles: disc/dot, circle, square
(default)
==> paired tag & block level
==> ul is parent of li tag
39 | P a g e
<li>Hyundai Creta ₹10.44 Lakh</li>
<li>Hyundai Grand ₹i10 Nios 5.39 Lakh</li>
<li>Hyundai i20 ₹7.03 Lakh</li>
</ul>
</ul>
</body>
</html>
<ul style="list-style-image:url(images/b.webp);">
<li>Google</li> <li>Microsoft</li> <li>Oracle</li> <li>Apple</li>
<li>Intel</li>
</ul>
<hr>
<ul>
<li style="list-style-image:url(images/b1.png);">Google</li>
<li style="list-style-image:url(images/ms.png);">Microsoft</li>
<li style="list-style-image:url(images/or.png);">Oracle</li>
<li style="list-style-image:url(images/ap.png);">Apple</li>
<li style="list-style-image:url(images/in.png);">Intel</li>
</ul>
40 | P a g e
</body>
</html>
41 | P a g e
<body>
<div style="background-color:#0000ff;color:white;width:500px;text-align:center; float:left;">
<h1>Hypertext Markup Language</h1>
<h1>Cascading Style Sheets</h1>
<h1>JavaScript</h1>
<h1>BootStrap</h1>
<h1>AngularJS</h1>
</div>
<div style="background-color:#0000ff;color:white;width:300px;text-align:center;float:left;">
<h1>Servlet</h1>
<h1>ASP.Net</h1>
<h1>PHP</h1>
<h1>NodeJS</h1>
<h1>Flask</h1>
</div>
<div style="background-color:#0000ff;color:white;width:300px;text-align:center;float:left;">
<h1>Oracle</h1>
<h1>MySQL</h1>
<h1>SQL-Server</h1>
<h1>DB/2</h1>
<h1>Teradata</h1>
</div>
</body>
</html>
42 | P a g e
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ex26</title>
<link rel="icon" href="logo1.png"/>
<style>
span{
font-size:30px;
}
</style>
</head>
<body>
<div style="display:flex; flex-direction:row; flex-wrap:wrap; gap:20px;">
<span style="background:#ff99ff;">SivaKumar</span>
<span style="background:#ffff66;">Venkatesh</span>
<span style="background:#33ffff;">Ram</span>
<span style="background:#99ff00;">Sumera</span>
<span style="background:#ff99ff;">Pravallika</span>
<span style="background:#ffff66;">Nag</span>
<span style="background:#33ffff;">Nasim</span>
<span style="background:#99ff00;">Srikanth</span>
<span style="background:#ff99ff;">Sameer</span>
<span style="background:#ffff66;">Hemanth</span>
<span style="background:#33ffff;">Srinivas</span>
<span style="background:#99ff00;">Raushan</span>
<span style="background:#ff99ff;">ManikyaRaju</span>
<span style="background:#ffff66;">Swetha</span>
<span style="background:#33ffff;">Vikram</span>
</div>
</body>
</html>
43 | P a g e
grid-column-gap ==> used to provide space between columns only
Syn: grid-column-gap:Npx;
</body>
</html>
44 | P a g e
<!-- CSS selectors
==> selector is a group of css-properties
==> selectors are used to define style sheets for html elements
==> we can create any no.of selectors (style sheets)
types: > universal sel
> tag sel
> id sel
> class sel
> group sel
> child sel
> direct child sel
> attribute sel
> pseudo classes
> pseudo elements
universal sel ==> used to define common styles for all html elements
==> 1 universal
Syn:- *{
property:value;
property:value;
...
}
45 | P a g e
<!-- CSS selectors
tag sel ==> used to define common styles for all instances of specific html elements
Syn:- tag-name{
property:value;
property:value;
...
}
tag-name{
property:value;
property:value;
...
}
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ex30</title>
<link rel="icon" href="logo1.png"/>
<style>
h1{
color:red;
}
label{
color:blue;
}
</style>
</head>
<body>
<h1>Samsung</h1>
<h1>Sony</h1>
<h1>LG</h1>
<label>Username</label>
<label>Password</label>
</body>
</html>
<!-- CSS selectors
id sel ==> used to define styles for 1 instance of specific html element
==> its alternative for inline styles
==> unique style
Syn:- #id-name{
property:value;
property:value;
...
}
mapping => we have to map id selector to some html tag by using "id" attribute
<tag id="id-name">
46 | P a g e
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ex31</title>
<link rel="icon" href="logo1.png"/>
<style>
#id1{
color:red;
}
#id2{
color:blue;
}
#id3{
color:green;
}
</style>
</head>
<body>
<h1 id="id1">Samsung</h1>
<h1 id="id2">Sony</h1>
<h1 id="id3">LG</h1>
<h1 id="id1">Onida</h1> <!-- invalid -->
</body>
</html>
mapping => we have to map class selector to some html tags by using "class" attribute
<tag class="class-name">
<tag class="class-name class-name class-name...">
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ex32</title>
<link rel="icon" href="logo1.png"/>
<style>
.c1{
color:red;
}
47 | P a g e
.c2{
color:blue;
}
</style>
</head>
<body>
<h1 class="c1">Samsung</h1>
<h1 class="c1">Sony</h1>
<h1 class="c2">LG</h1>
<h1 class="c2">Onida</h1>
<h1 class="c2">TCL</h1>
</body>
</html>
<h1 class="c2">LG</h1>
<h1 class="c2">Onida</h1>
<p class="c2">EDITPLUS IS SOLD "AS IS" AND WITHOUT ANY WARRANTY AS TO
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR ANY OTHER WARRANTIES EITHER
EXPRESSED OR IMPLIED.</p>
<span class="c2">invalid user</span>
<span class="c2">invalid password</span>
</body>
</html>
48 | P a g e
<!-- class selectors -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ex33</title>
<link rel="icon" href="logo1.png"/>
<style>
.c1{
color:red;
}
.c2{
background-color:yellow;
text-align:justify;
}
</style>
</head>
<body>
<p class="c1 c2">EditPlus is not free software. You may use this software for evaluation
purposes without charge for a period of 30 days. If you use this software after the 30 day evaluation
period, you must buy the license.</p>
</body>
</html>
49 | P a g e
<h1 class="c2">Yellow Mango</h1>
<h1 class="c3">Black Grape</h1>
<h1 class="c3">Green Banana</h1>
<h1 class="c3">Oranges</h1>
</body>
</html>
50 | P a g e
<p>Do not hesitate to asků because we will work according to your
calendar</p>
</div>
<div class="content"> <!-- content 4 -->
<img src="images/icon4.png"/>
<h2>Industry Specific Scenarios</h2>
<p>Students are provided with all the Real-Time and Relevant
Scenarios</p>
</div>
<div class="content"> <!-- content 5 -->
<img src="images/icon5.png"/>
<h2>e-Learning Sessions</h2>
<p>Online training sessions are held Live and we provide students with
the Training Videos</p>
</div>
<div class="content"> <!-- content 6 -->
<img src="images/icon6.png"/>
<h2>24/7 Support</h2>
<p>No Problem@ allů!!! Your Question will be answered by Us at any
Hour of the time</p>
</div>
</div>
</body>
</html>
block ==> css option, used to display inline tags like as block level tags (line-by-line)
Syn: display:block;
51 | P a g e
<h2 style="background:yellow; display:inline;">Oracle</h2>
<hr>
<!-- inline ==> block -->
<label style="background:cyan; display:block;">Google</label>
<label style="background:pink; display:block;">Microsoft</label>
<label style="background:yellow; display:block;">Oracle</label>
<hr>
<input type="radio" name="r"
onchange="document.getElementById('d').style.display='block'"/>Show
<input type="radio" name="r"
onchange="document.getElementById('d').style.display='none'"/>Hide
<br>
52 | P a g e
<!-- example on tables
table ==> used to draw a table/ used to comb rows
caption ==> used to set main heading of table
tr ==> table row, used to draw a row (comb columns => th or td)
th ==> table heading, used to column headings
td ==> table data, used to display data in columns
53 | P a g e
<!-- example on tables -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ex39</title>
<link rel="icon" href="logo1.png"/>
</head>
<body>
<table border="5" align="center" width="500px" style="background:cyan;color:red;">
<caption>List Of Students</caption>
<tr>
<th>Slno</th> <th>Name</th> <th>Contact no</th> <th>Course</th>
</tr>
<tr>
<td>1</td> <td>Ram</td> <td>9855098550</td> <td>C lang</td>
</tr>
<tr>
<td>2</td> <td>Sam</td> <td>9879898700</td> <td>Java</td>
</tr>
<tr>
<td>3</td> <td>Rahim</td> <td>7867867869</td> <td>HTML-
JavaScript</td>
</tr>
</table>
</body>
</html>
first-child ==> to apply some styles on 1st positioned child tag of some parent tag
Syn: tag/id/class:first-child{
......
}
last-child ==> to apply some styles on last positioned child tag of some parent tag
Syn: tag/id/class:last-child{
......
}
nth-child ==> to apply some styles on nth positioned child tag of some parent tag
Syn: tag/id/class:nth-child(POS/even/odd){
......
}
54 | P a g e
hover ==> hand over
==> applying some styles on html elements whenevere mouse enters on that tag
Syn tag/id/class:hover{
......
}
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ex40</title>
<link rel="icon" href="logo1.png"/>
<style>
/* li:first-child{
color:red;
}
li:last-child{
color:red;
}
li:nth-child(2n+3){
color:red;
} */
li:hover{
color:blue;
}
</style>
</head>
<body>
<ol>
<li>One</li>
<li>Two</li>
<li>Three</li>
<li>Four</li> <li>Five</li> <li>Six</li>
<li>apple</li>
</ol>
</body>
</html>
55 | P a g e
}
caption{
color:#3300ff;
text-align:left;
}
table{
width:80%;
font-size:16px;
font-weight:bold;
border-collapse:collapse;
box-shadow:1px 1px 2px 2px #ff00ff;
}
tr:nth-child(even){
background:#3300ff;
color:white;
}
tr:nth-child(odd){
background:#ff0033;
color:white;
}
tr:first-child{
background:#ffff00;
color:#3300cc;
font-size:18px;
}
tr:hover{
background:black;
color:#ccff00;
}
span{
display:inline-block;
width:20px;
height:20px;
color:black;
text-align:center;
}
.w{
background:#00ff00;
}
.l {
background:#ff9900;
}
</style>
</head>
<body>
<table align="center">
<caption>IPL 2022 Points Table</caption>
<tr>
56 | P a g e
<th>POS</th> <th>TEAM</th> <th>MATCHES</th> <th>WON</th>
<th>LOST</th> <th>PTS</th> <th>NRR</th> <th>Form</th>
</tr>
<tr>
<td>1</td> <td><img src="images/gt.png"/>Titans</td> <td>14</td>
<td>10</td> <td>4</td> <td>20</td> <td>+0.316</td>
<td> <span class="l">L</span> <span class="w">W</span> <span
class="w">W</span> <span class="w">W</span> </td>
</tr>
<tr>
<td>2</td> <td><img src="images/rr.png"/>Royals</td> <td>14</td> <td>9</td>
<td>5</td> <td>18</td> <td>+0.298</td>
</tr>
<tr>
<td>3</td> <td><img src="images/lsg.png"/>Super Giants</td> <td>14</td>
<td>9</td> <td>5</td> <td>18</td> <td>+0.251</td>
</tr>
<tr>
<td>4</td> <td><img src="images/rcb.png"/>Royal Challengers</td>
<td>14</td> <td>8</td> <td>6</td> <td>16</td> <td>-0.253</td>
</tr>
<tr>
<td>5</td> <td><img src="images/dc.png"/>Capitals</td> <td>14</td>
<td>7</td> <td>7</td> <td>14</td> <td>+0.204</td>
</tr>
<tr>
<td>6</td> <td><img src="images/pbks.png"/>Kings</td> <td>14</td>
<td>7</td> <td>7</td> <td>14</td> <td>+0.126</td>
</tr>
<tr>
<td>7</td> <td><img src="images/kkr.png"/>Knight Riders</td> <td>14</td>
<td>6</td> <td>8</td> <td>12</td> <td>+0.146</td>
</tr>
<tr>
<td>8</td> <td><img src="images/srh.png"/>Sunrisers</td> <td>14</td>
<td>6</td> <td>8</td> <td>12</td> <td>-0.379</td>
</tr>
<tr>
<td>9</td> <td><img src="images/csk.png"/>Super Kings</td> <td>14</td>
<td>4</td> <td>10</td> <td>8</td> <td>-0.203</td>
</tr>
<tr>
<td>10</td> <td><img src="images/mi.png"/>Indians</td> <td>14</td>
<td>4</td> <td>10</td> <td>8</td> <td>-0.506</td>
</tr>
</table>
</body>
</html>
57 | P a g e
<!-- example on tables
colspan ==> used to mearge multiple columns into single col
==> displaying common heading or common data for column
==> th or td
58 | P a g e
</html>
<!-- example on "input" tag
input tag ==> used to create input elements or fields or controls
==> input elements are used to accept data from user
==> unpaired & inline tag
==> lacks & 1 line only
Syn: <input type=" " .../>
type => text, password, number, hidden, reset, submit, image, checkbox, radio,
email, url, date, time, file,...
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ex43</title>
<link rel="icon" href="logo1.png"/>
</head>
<body>
<h3>demo on text fields</h3>
<!-- <input/> -->
<input type="text" autofocus/>
<input type="text" maxlength="10"/>
<br>
<input type="text" size="5"/>
<br>
<input type="text" id="tb1" name="tf1"/>
<br>
<input type="text" id="tb2" name="tf2" placeholder="enter firstname"/>
<br>
<label>enter lastname</label>
<input type="text" id="tb3" name="tf3"/>
<br>
<input type="text" id="aa" name="aa" value="124"/>
<br>
<input type="text" id="bb" name="bb" value="apple" readonly/>
<br>
<input type="text" id="cc" name="c" required/>
</body>
</html>
59 | P a g e
<h3>demo on password field</h3>
<label>enter password</label> <br>
<input type="password" id="pw" name="pw"/> <bR>
<label>enter cvv</label> <br>
<input type="password" id="cvv" name="cvv"/> <bR>
<label>enter pin</label> <br>
<input type="password" id="pin" name="pin"/> <bR>
</body>
</html>
</body>
</html>
61 | P a g e
<body>
<h3>demo on form </h3>
<form id="f" action="test.jsp" method="post" autocomplete="on">
<input type="text" name="tf1"/> <bR>
<input type="text" name="tf2"/> <bR>
<input type="submit" name="sb"/> <br>
</form>
</body>
</html>
62 | P a g e
<html lang="en">
<head>
<title>Ex51</title>
<link rel="icon" href="logo1.png"/>
</head>
<body>
<h3>demo on checkbox field</h3>
<form id="frm1" action="test">
<label>RAM:</label> <bR>
<input type="checkbox" id="ram1" name="ram" value="12" checked/>
<label>12gb & Above</label> <br>
<input type="checkbox" id="ram2" name="ram" value="8"/>
<label>8gb</label> <br>
<input type="checkbox" id="ram3" name="ram" value="6"/>
<label>6gb</label> <br>
<input type="checkbox" id="ram4" name="ram" value="4"/>
<label>4gb</label> <br>
<input type="checkbox" id="ram5" name="ram" value="3"/>
<label>3gb</label> <br>
<input type="checkbox" id="ram6" name="ram" value="2"/>
<label>2gb & Below</label> <br>
<br>
<label>BRAND:</label> <br>
<input type="checkbox" id="brn1" name="brand" value="samsung" checked/>
<label>Samsung</label>
<input type="checkbox" id="brn2" name="brand" value="nokia" checked/>
<label>Nokia</label>
<input type="checkbox" id="brn3" name="brand" value="vivo" checked/>
<label>Vivo</label>
<input type="checkbox" id="brn4" name="brand" value="one"/>
<label>OnePlus</label>
<input type="checkbox" id="brn5" name="brand" value="mi"/>
<label>Redmi</label> <br>
<input type="checkbox" id="brn6" name="brand" value="oppo"/>
<label>Oppo</label>
<input type="checkbox" id="brn7" name="brand" value="poco"/>
<label>Poco</label>
<input type="checkbox" id="brn8" name="brand" value="apple"/>
<label>Apple</label>
<input type="checkbox" id="brn9" name="brand" value="realme"/>
<label>Realme</label>
<input type="checkbox" id="brn10" name="brand" value="moto"/>
<label>Moto</label> <br>
<input type="submit"/>
</form>
</body>
</html>
63 | P a g e
<!-- example on "input" tag -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ex52</title>
<link rel="icon" href="logo1.png"/>
</head>
<body>
<h3>demo on radio buttons</h3>
<form id="frm1" action="test">
<label>Gender</label> <bR>
<input type="radio" id="gen1" name="gender" value="male" checked/>
<label>Male</label>
<input type="radio" id="gen2" name="gender" value="female"/>
<label>FeMale</label>
<input type="radio" id="gen3" name="gender" value="other"/>
<label>Others</label>
<br>
<label>Marital Status:</label> <bR>
<input type="radio" id="ms1" name="ms" value="single" checked/>
<label>Single</label>
<input type="radio" id="ms2" name="ms" value="married"/>
<label>Married</label>
<input type="radio" id="ms3" name="ms" value="divorced"/>
<label>Divorced</label>
<input type="radio" id="ms4" name="ms" value="widowed"/>
<label>Widowed</label>
<input type="radio" id="ms5" name="ms" value="nun"/>
<label>Never married</label>
<br>
<input type="submit"/>
</form>
</body>
</html>
64 | P a g e
<body>
<h3>demo on email, url, date, time & datetime controls</h3>
<form id="frm1" action="test">
<label>enter email id</label>
<input type="email" id="mid" name="mid"/>
<br>
<label>enter url</label>
<input type="url" id="url" name="url"/>
<br>
<label>enter date</label>
<input type="date" id="d" name="d"/>
<br>
<label>date of birth</label>
<input type="date" id="dob" name="dob" min="1970-01-01" max="2022-08-03"/>
<br>
<label>time</label>
<input type="time" id="t" name="t"/>
<br>
<label>date & time</label>
<input type="datetime-local" id="dt" name="dt"/>
<br>
<!-- <input type="submit"/> OR -->
<button>Submit</button>
</form>
</body>
</html>
65 | P a g e
<a href="ex50.html">Login</a>
</body>
</html>
66 | P a g e
<!-- example on "input" tag -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ex54</title>
<link rel="icon" href="logo1.png"/>
</head>
<body>
<h3>demo on file control </h3>
<form id="frm1" action="test">
<input type="file" id="f1" name="f1"/> <!-- 1file, any type, any size -->
<br>
<input type="file" id="f2" name="f2" multiple/>
<br>
<input type="file" id="f3" name="f3" accept=".pdf,.docx"/>
<!-- accept="image/*" accept="audio/*" accept="video/*" -->
<br>
<button>Upload</button>
</form>
</body>
</html>
67 | P a g e
</head>
<body>
<h3>demo on dropdown control</h3>
<label>Mode of Training</label>
<select id="mot" name="mot">
<option value="">Select Training Type</option>
<option value="classroom">Classroom Training</option>
<option value="online">Online Training</option>
<option value="project">Project Training</option>
<option value="placement" selected>Placement Training</option>
<option value="internship">Internship</option>
<option value="weekend">Weekend Training</option>
</select>
<label>Course</label>
<select id="course" name="course">
<option value="">Select Course</option>
<option value="c">C</option>
<option value="cpp">C++</option>
<option value="cj">Corejava</option>
<option value="aj">AdvJava</option>
<option value="fsj">Full Stack Java</option>
<option value="spring">Spring</option>
<option value="asp">ASP.net</option>
<option value="c#">C#.net</option>
<option value="fsn">Full Stack .Net</option>
<option value="python">Python</option>
<option value="dj">Django</option>
<option value="html-js" selected>Html-JavaScript</option>
<option value="angular">Angular</option>
<option value="react">React</option>
<option value="node">NodeJS</option>
<option value="php">PHP</option>
<option value="xml-ws">XML/WebServices</option>
<option value="oracle">Oracle</option>
<option value="mysql">MySQL</option>
<option value="sql-server">SQL-Server</option>
<option value="db2">DB/2</option>
<option value="tera">Teradata</option>
</select>
</body>
</html>
68 | P a g e
<!-- example on "datalist" & "option" tags -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ex57</title>
<link rel="icon" href="logo1.png"/>
</head>
<body>
<h3>demo on search box</h3>
<input type="text" list="menu"/>
<datalist id="menu">
<option>Alu 65</option>
<option>Veg. Spring Roll</option>
<option>Veg. Crispy</option>
<option>Gobi 65</option>
<option>Veg. Manchuria</option>
<option>Veg. Shangai Roll</option>
<option>Bhutan Veg.</option>
<option>Veg. Sheekh Kebab</option>
<option>Veg. Tabla Special Roll</option>
<option>Paneer 65</option>
<option>Baby Corn 65</option>
<option value="Chicken Spring Rolls"/>
<option value="Chicken Drumsticks"/>
<option value="Bhutan Chicken"/>
<option value="Chicken 65"/>
<option value="Chicken Manchuria"/>
<option value="Chicken Majestic"/>
<option value="Szechuan Chicken"/>
<option value="Chicken Roll"/>
<option value="Chicken">Chicken Fry</option>
</datalist>
</body>
</html>
69 | P a g e
<details>
<summary>Colors</summary>
<ul>
<li>Red</li> <li>Green</li> <li>Blue</li> <li>Yellow</li>
</ul>
</details>
<br>
<details>
<summary>Login</summary>
<div>
<h3>Login Form</h3>
<form id="f" action="login.jsp" method="post">
<p>
<label>Username</label> <span>*</span> <br>
<input type="text" id="una" class="text" name="una" required/>
</p>
<p>
<label>Password</label> <span>*</span> <br>
<input type="password" id="pwd" class="text" name="pwd" required
autocomplete="off"/>
</p>
<p>
<input id="button" type="submit" name="sb" value="Log In"/>
</p>
<hr>
<p>
<a href="newuser.html">Create new user</a> <br>
<a href="forgotpw.html">Forgotten password</a>
</p>
</form>
</div>
</body>
</html>
70 | P a g e
<p>EDITPLUS IS SOLD "AS IS" AND <mark>WITHOUT ANY WARRANTY</mark> AS TO
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR ANY OTHER WARRANTIES EITHER
EXPRESSED OR IMPLIED. THE <mark>AUTHOR WILL NOT BE LIABLE</mark> FOR DATA LOSS,
DAMAGES, LOSS OF PROFITS OR ANY OTHER KIND OF LOSS WHILE USING OR MISUSING THIS
SOFTWARE.</p>
<bdi>apples</bdi> <bdi>selppa</bdi>
<br>
200+
<img src="icon1.png"/>
<img src="icon2.png"/>
<img src="icon3.png"/>
</body>
</html>
</body>
</html>
71 | P a g e
<video controls src="files/Cartoons.mp4" width="600px" height="400px">video format not
supported</video>
<video controls src="files/Beast.mp4" muted autoplay loop></video>
<video controls src="files/Beast.mp4" poster="images/b.webp"></video>
</body>
</html>
</body>
</html>
72 | P a g e
place here sub content, promos
</aside>
</main>
<footer>
place here contact info, emailid, sm links, terms & conditions...
</footer>
</body>
</html>
</head>
<body>
<h3>demo on meta</h3>
<h4>page refreshing automatically for every 5sec once</h4>
<script>
document.write( Math.random() +"<br>" );
document.write( new Date().toLocaleTimeString() );
</script>
</body>
</html>
73 | P a g e
</head>
<body id="b">
<h3>auto redirectig page</h3>
<h3>plz wait 10sec, we are flying to another page</h3>
<script>
let c = "#"+parseInt(Math.random()*1000000);
document.getElementById(`b`).style.backgroundColor=c;
</script>
</body>
</html>
<!--
attribute selector
==> used to define common styles for html elements but based on attribute name (html
only)
Syn: [attribute]{
prop:value;
prop:value;
...
}
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>C1</title>
<meta charset="UTF-8"/>
<style>
[height]{
color:red;
}
[width="200px"]{
color:blue;
}
input[type="text"]{
color:green;
}
input[type="password"]{
color:cyan;
}
</style>
</head>
<body>
<h1>HTML</h1>
<h1 height="40px">CSS</h1>
<h1 height="30px">JavaScript</h1>
<h2 height="40px">BootStrap</h2>
<h3 height="20px">Angular</h3>
74 | P a g e
<h1 width="100px">Apple</h1>
<h1 width="200px">Mango</h1>
<h2 width="200px">Orange</h2>
<h3 width="200px">Grape</h3>
<!--
group selector
==> used to define common styles for group of html elements
Syn: tag1, tag2, tag3, ...{
prop:value;
prop:value;
...
}
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>C1</title>
<meta charset="UTF-8"/>
<style>
label,span{
color:red;
}
h1,h2,h3,h4,h5,h6{
color:blue;
}
</style>
</head>
<body>
<label>Username</label> <span>*</span><bR>
<label>Password</label> <span>*</span><bR>
<h1>HTML</h1>
<h1>CSS</h1>
<h2>JavaScript</h2>
<h2>BootStrap</h2>
<h3>Angular</h3>
<h4>Apple</h4>
<h5>Mango</h5>
75 | P a g e
<h6>Orange</h6>
<!--
child selector
==> used to define common styles for child/grand child.. html elements
Syn: p-tag c-tag {
prop:value;
prop:value;
...
}
gp-tag p-tag c-tag {
prop:value;
prop:value;
...
}
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>C1</title>
<meta charset="UTF-8"/>
<style>
nav a{
color:red;
text-decoration:none;
}
footer a{
color:green;
text-decoration:none;
}
</style>
</head>
<body>
<a href="aa.html">goto AA</a> <bR>
<a href="bb.html">goto BB</a> <bR>
<nav>
<a href="h.html">Home</a> <bR>
<a href="s.html">Services</a> <bR>
<a href="a.html">About Us</a> <bR>
</nav>
<footer>
<div>
<a href="f.html">facebook</a> <bR>
<a href="y.html">youbute</a> <bR>
<a href="in.html">instagram</a> <bR>
76 | P a g e
</div>
</footer>
<!--
direct child selector
==> used to define common styles for only child html elements
Syn: p-tag > c-tag {
prop:value;
prop:value;
...
}
gp-tag > p-tag > c-tag {
prop:value;
prop:value;
...
}
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>C1</title>
<meta charset="UTF-8"/>
<style>
nav > a{
color:red;
text-decoration:none;
}
footer > a{
color:green;
text-decoration:none;
}
</style>
</head>
<body>
<a href="aa.html">goto AA</a> <bR>
<a href="bb.html">goto BB</a> <bR>
<nav>
<a href="h.html">Home</a> <bR>
<a href="s.html">Services</a> <bR>
<a href="a.html">About Us</a> <bR>
</nav>
<footer>
<div>
<a href="f.html">facebook</a> <bR>
<a href="y.html">youbute</a> <bR>
77 | P a g e
<a href="in.html">instagram</a> <bR>
</div>
</footer>
</body>
</html>
<!--
pseudo elements:
before, after, first-letter, first-line, selection, marker,
placeholder
Syn:- selector::pseudo-ele{
prop:value;
prop:value;
...
}
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>C5</title>
<meta charset="UTF-8"/>
<style>
h1::before{
content:"@ ";
}
h1::after{
content:url(images/s.png);
}
p::first-letter{
font-size:32px;
color:#3300ff;
background:#ffff00;
}
p::first-line{
color:#ff0000;
}
[type="text"]::placeholder{
color:#00ffff;
}
[type="password"]::placeholder{
color:#ff99ff;
}
ol,ul{
color:#009900;
}
::marker{
color:#cc00ff;
font-size:20px;
78 | P a g e
}
::selection{
background:black;
color:#ffff00;
}
</style>
</head>
<body>
<ol>
<li>One</li> <li>Two</li> <li>Three</li>
</ol>
<ul>
<li>One</li> <li>Two</li> <li>Three</li>
</ul>
<h1>Microsoft</h1>
<h1>Google</h1>
<h1>Oracle</h1>
<h2>SAP</h2>
<p>EDITPLUS IS SOLD "AS IS" AND WITHOUT ANY WARRANTY AS TO MERCHANTABILITY
OR FITNESS FOR A PARTICULAR PURPOSE OR ANY OTHER WARRANTIES EITHER EXPRESSED OR
IMPLIED. THE AUTHOR WILL NOT BE LIABLE FOR DATA LOSS, DAMAGES, LOSS OF PROFITS OR ANY
OTHER KIND OF LOSS WHILE USING OR MISUSING THIS SOFTWARE.</p>
<p>You may copy the evaluation version of this software and documentation as you wish,
and give exact copies of the original evaluation version to anyone, and distribute the evaluation
version of the software and documentation in its unmodified form via electronic means. But you
should not charge or requesting donations for any such copies however made and from distributing
the software and/or documentation with other products without the author's written
permission.</p>
</body>
</html>
<!--
pseudo elements:
before, after, first-letter, first-line, selection, marker,
placeholder
Syn:- selector::pseudo-ele{
prop:value;
prop:value;
...
}
79 | P a g e
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>C6</title>
<meta charset="UTF-8"/>
<style>
*{
margin:30px;
}
h1{
color:red;
}
.c{
background:yellow;
}
</style>
</head>
<body>
<h1 class="c">Microsoft</h1>
<h1>Google</h1>
<h2>Oracle</h2>
</body>
</html>
<!--
pseudo elements:
before, after, first-letter, first-line, selection, marker,
placeholder
Syn:- selector::pseudo-ele{
prop:value;
prop:value;
...
}
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>C6</title>
<meta charset="UTF-8"/>
<style>
h1,h2,h3,h4,h5,h6{ .... };
#id-h1,#id-h2,#id-h3{ .... };
.main-cont,.sub-cont,.nested-cont{ .... };
ul li,ol li{ ... }
80 | P a g e
</style>
</head>
<body>
<h1 class="c">Microsoft</h1>
<h1>Google</h1>
<h2>Oracle</h2>
</body>
</html>
<!--
pseudo elements:
before, after, first-letter, first-line, selection, marker,
placeholder
Syn:- selector::pseudo-ele{
prop:value;
prop:value;
...
}
css preferenace:
> default
> universal
> tag
> dir child
> child
> class
> attribute
> id
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>C8</title>
<meta charset="UTF-8"/>
<style>
h1{
background:#ff0033;
}
.c{
background:#ff00ff;
}
#i{
background:#006600;
}
div h1{
background:#3300ff;
81 | P a g e
}
</style>
</head>
<body style="color:white;">
<h1>Microsoft</h1>
<div>
<h1 id="i" class="c">Siva Kumar Y</h1>
</div>
</body>
</html>
82 | P a g e
JAVA SCRIPT
What is Scripting?
A script is program code that doesn’t need pre-processing (e.g. compiling) before being run. In the
context of a Web browser, scripting usually refers to program code written in JavaScript that is
executed by the browser when a page is loaded, or in response to an event triggered by the user.
Scripting can make Web pages more dynamic. For example, without reloading a new version of a
page it may allow modifications to the content of that page, or allow content to be added to or sent
from that page. The former has been called DHTML (Dynamic HTML), and the latter AJAX
(Asynchronous JavaScript and XML).
Modifications of the content using the DOM by the user and by scripts trigger events that
developers can make use of to build rich user interfaces.
Client-sidescript: These scripts are getting executed within the web Browser (client). Here we don’t
need any software. These scripts are used for client-side validations (data verification & data
validations)
Ex: JavaScript, VBScript, typescript, etc…
Server-side script: A script which executes in server machine with support of the web-server/app-
server software’s like IIS(Internet information services), Tomcat, JBOSS, etc.These scripts are used
for server-sidevalidations (authentication & authorization).
Ex:php, jsp, asp.net, nodeJS, cgi, perletc…
83 | P a g e
JavaScript Introduction
In 1995, JavaScript was created by a Netscape developer named “Brendan Eich”. First, it was
called Mocha. Later, it was renamed LiveScript.
When JavaScript was created, it initially had another name: “LiveScript”. But Java was very
popular at that time, so it was decided that positioning a new language as a “younger brother”
of Java would help.
But as it evolved, JavaScript became a fully independent language with its own specification
called ECMAScript, and now it has no relation to Java at all.
ECMAScript/ES JS
Later JavaScript became an ECMA(European Computer Manufacturers AssociationScript)
(ES)standard in 1997. ECMAScript is the official name of the language.
JavaScript is implementation of ES; ES is the specification of JavaScript. RBI SBI,
HDFC,ICICI customer
ES JS Programmer
JQuery
JSON
Angular
NodeJS
ReactJS
These tech & frameworks using JavaScript as their PL
A=10
A=10.56
A=”ram”
JavaScript is a Speed, light weight, Interoperability, Extended Functionality, dynamic, loosely
typed, single threaded, free ware and open-source.
84 | P a g e
JavaScript Translator is responsible to translate the JavaScript code which is embedded in
browser.
Parser’s:
Html code (high) => html parser => machine code
Css code (high) =>css parser => machine code
JS code (high) =>js parser => machine code
Every browser they have own JS engine:
V8 Chrome and Opera.
SpiderMonkey Firefox.
Chakra IE
JavaScriptCore, and SquirrelFish Safari
V8 Edge
JavaScript is “interpreter-based” programming, means the code will be converted into machine
language line-by-line. JavaScript interpreter is already embedded in Browsers.
Using HTML/CSS, we can only design a web page but it’s not supported to perform logical
operations such as calculations, decision making and repetitive tasks, dynamically displaying output,
reading inputs from the user, and updating content on webpage at client side. Hence to perform
these entire tasks at client side we need to use JavaScript.
Where it is used?
There are so many web applications running on the web that are using JavaScript like Google,
Facebook,twitter, amazon, YouTube etc.
It is used to create interactive websites. It is mainly used for:
1. Client-side verifications and validation
2. Dynamic drop-down menus
3. Displaying date and time
4. Build forms that respond to user input without accessing a server.
5. Displaying popup windows and dialog boxes (like alert dialog box, confirm dialog box and
prompt dialog box)
6. Manipulate HTML "layers" including hiding, moving, and allowing the user to drag them around
a browser window.
etc...
Limitations of JavaScript
85 | P a g e
4. it doesn't support db connections.
JavaScript Versions
Version Officeal Name Release Date
1 ECMAScript 1 June-1997
2 ECMAScript 2 June-1998
3 ECMAScript 3 Dec-1998
5 ECMAScript 5 Dec-2009
6 ECMAScript June-2015
7 ECMAScript June-2016
8 ECMAScript June-2017
>internal scripting
Internal script is nothing but html code and javascript code both are placed in the same file, but
not in same line.
Internal script must be implemented inside <script> tag, <script> is a paired tag.
> scripting in head sec
head is first executed part of html, hence javascript is also executes first.
<head>
<script type="text/javascript”>
JS code
</script>
86 | P a g e
</head>
> scripting in body sec
body level script is executed after head section
<body>
<script type="text/javascript”>
JS code
</script>
</body>
fun-name();
function fun-name()
{
Steps
}
OR
Steps
}
Syn:
<script src="filename1.js"></script>
<script src="filename2.js"></script>
87 | P a g e
Comments in JavaScript
Comment is nothing but it is a statement which is not display on browser window. It is useful to
understand which code is written for what purpose.
Comments are useful in every programming language to deliver message. It is used to add
information about the code, warnings or suggestions so that the end user or other developer can
easily interpret the code.
Types of Comments:
There are two types
es of comments are in JavaScript
1. Single-line Comment ex: //comment
Single-line Comment
It is represented by double forward slashes //. It can be used before any statement.
Example:
<script>
// It is single line comment
document.write("Hello Javascript");
</script>
Multi-line Comment
It can be used to add single as well as multi line comments.
It is represented by forward slash / with asterisk * then asterisk with forward slash.
Example:
<script>
/* It is multi line comment.
It will not be displayed */
88 | P a g e
document.write("Javascript multiline comment");
</script>
write() method: The write() method writes HTML expressions or javascript code to a document
without line breaking.
Syn: document.write(val1, val2, val3, ….);
document.write(exp1 + exp2 + exp3 + ...);
writeln() method: The writeln() method writes HTML expressions or javascript code to a document
with line breaking.
Syn: document.writeln(exp1,exp2,exp3, ...);
document.writeln(exp1 + exp2 + exp3 + ...);
log() method: The log() method writes HTML expressions or javascript code on browser’s console
(press F12) with line break.
Syn: console.log(exp1,exp2,exp3, ...);
console.log(exp1 + exp2 + exp3 + ...);
89 | P a g e
Example:
<html>
<head>
<script type='text/javascript'>
document.write("<h1>hello world!</h1><p> have a nice day ! </p>");
</script>
</head>
</html>
writeln() method: The writeln() method is similar to the write method, with the addition of writing a
newline character after each statement.
Syn:document.writeln(exp1,exp2,exp3 ...)
Example:
<!DOCTYPE html>
<html>
<body>
<pre>
<script type='text/javascript'>
document.writeln("Welcome to JS");
document.writeln("Welcome to JS");
</script>
</pre>
</head>
</html>
Note: You have to place writeln() in pre tag to see difference between write() and writeln().
Writeln() actually produces the output in new line (\n) but browser will not detect the \n as
linebreak, hence to show it correctly and keep format as it is we will use pre tag.
Example:
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
document.write("<h1 style='color:blue; font-size:30px; font-family:tahoma'>
Welcome To JS</h1>");
document.write("<font color='green' size='16px' face='Arial'> Welcome To
JS</font>");
</script>
</head>
<body>
90 | P a g e
</body>
</html>
Note:
the above type of code is known as DHTML
In JavaScript a string should be in single or double quotes.
Double quotes inside using single quotes are valid, single quotes inside using double quotes
valid.
Example
<!DOCTYPE html>
<html>
<body>
<script>
document.write("JavaScript is client side script");
document.write("<br>");
document.write("JavScript is 'ECMA' Implementation<br>");
document.write('JavScript released by NetScape<br>');
document.write('NetScape release "Mocha"<br>');
//document.write('NetScape release 'Mocha'<br>'); Error
//document.write("NetScape release "Mocha"<br>"); Error
</script>
</body>
</html>
JavaScript string with escape sequences: An escape character is consisting of backslash "/" symbol
with an alphabet. The following are frequently using escape characters.
1. \n : inserts a new line
2. \t : inserts a tab space
3. \r : carriage return
4. \b : backspace
5. \f : form feed
6. \' : single quote
7. \”: double quote
8. \\ : Backslash
document.write();
91 | P a g e
| |
page method
ex:
<head>
<script type='text/javascript'>
window.document.write("livescript is javascript");
document.write("<br>");
document.write('livescript is javascript');
</script>
</head>
JavaScript semicolon(;):
In javascript every statements ends with semicolon(;). It is an optional notation.
ex:
<head>
<script type='text/javascript'>
document.write=("livescript is javascript");
</script>
</head>
ex:
<head>
<script type='text/javascript'>
document.write("javascript");
document.write('livescript');
document.write('livescript is javascript');
</script>
</head>
Note:
1) In the above script semicolon(;) is mandatory.
2) It is a good programming practice to use the semicolon.
ex:
<head>
92 | P a g e
<script type='text/javascript'>
document.write("welcome to head section");
</script>
</head>
<body>
<script language="javascript">
document.write("welcome to the body section");
</script>
</body>
External javascript:
Javascript can also be placed in a external files,these files contains javascript code. This code we can
apply on different webpages. External javascript files extensions is .js
Note:
1) External script cann't contain the <script></script> tags.
2) To use an external script,point to the .js file in the "src" attribute of the <script> tag.
Javascript blocks: JavaScript sentences can be group together in blocks. Blocks starts with a left curly
bracket { and end with a right curly bracket }. The purpose of your block is to make the sequence of
statement excute together.
<head>
<script type="text/javascript">
{
93 | P a g e
document.write(This is a block);
}
</script>
</head>
JS Naming Conventions
abstract, boolean, break, byte,, case, catch, char, class, const,, continue, debugger, default, delete,
do, double,, else, enum, export, extends, false, final, finally, float,, for, function, goto, if, implements,
imp
import, instanceof, int,, interface, let, long,, native, new, null, package, private, protected, public,
return, short,, static, super, switch, synchronized, this, throw, throws, transient, true, try, typeof,
var,, void, volatile, while, with. 59
working with Variables
Java script did not provide any data types for declaring variables and a variable in javascript can
store any type of value. Hence java script is loosely typed programme.
We can use a variable directly without declaring it in javascript, it’s called dynamic
dynam programming.
for example:
var eid; var 1a;
var total; var a1;
var _b; var book id;
var a@; var studentid;
var #b; var case;
var book_id; var a$1
<script>
var a=10;
var b=20;
var c=a+b;
95 | P a g e
document.write(c);
</script>
Output 30
Types of Variable in JavaScript
Local Variable
Outer/Global Variable
Local Variable
A variable which is declared inside block or function is called local variable. It is accessible within the
function or block only.
For example:
<script>
functionabc()
{
var x=10; //local variable
}
</script>
or
Example
<script>
If(10<13)
{
var y=20;//javascript local variable
}
</script>
Global Variable
var is declared with in script tag but outside function & block those are global variables.
these global variables are accessible from anywhere in program.
declared with window object is known as global variable.
For example:
<script>
var value=10;//global variable
function a()
{
alert(value);
}
function b()
{
alert(value);
}
</script>
For example:
function m()
{
window.value=200; //declaring global variable by window object
}
function n()
{
alert(window.value); //accessing global variable from other function
}
Scripts are able to support implicit declaration but languages are only explicit declaration.
Note:: Explicit declaration is always recommended as a good programming practice.
Javascript datatypes:
In javascript data types are classified into the follow
following two cat.
1. Primitive datatypes
2. non-primitive datatypes
97 | P a g e
var st1 = new String();
typeof
typeof is predefine function, and it's used to identify datatype of a variable or value.
Syn: typeof var-name
typeof value
Dynamic data types:: Javascript has dynamic types.This means that the same variable can be used as
different types.
ex:
var x; //now x is undefined
var x=5; // now x is a number
var x="ram"; // now x is a String
Non-primitive data types: When a variable is declared with the keyword new, the variable is an
object.
new is used for dynamic memory allocations (for creating objectsand arrays).
these datatypes are also called as reference datatype.
Ex:
var st=newString();
var x=newNumber();
let y=newBoolean();
let a = [ ];
here LHS are reference variables, and RHS are objects.
reference variables are storing address of dynamic memory (object)
JavaScript operators
operator is a symbol (special char) and it is used to perform certain operation(task).
every operator is a symbol, but every symbol is not operator.
every operator requires some values, those are called as operands.
Ex:
Expression
Its combination of one operator and some operands
Cat:
99 | P a g e
Unary it req one operand
Binary it req two operands
Arithmetic
Relational
Logical
Bitwise
Assignment
Concatenation
Ternary it req three operands
Arithmetic operators: using these operators we can perform the basic math calculations.
Ope are + - * / % **
operators are:
operator Description example
+ addition j+12
- subtraction j-22
* multiplication j*7
/ division j/3
% modulus j%6
** power x**y xy
relational operators: these operators are used to provide comparison between two operands. these
are boolean operators (true/false).
Operators are: > < >= <= == != === !==
Logical operators: these operators are used to perform multiple comparisons @time. these are
boolean operators (true/false).
Operators are: && || !
100 | P a g e
And Or Not
Cond1 Cond2 Result Cond1 Cond2 Result Cond Result
T T T T TT T F
T F F T F T F T
F T F F T T
F F F F FF
assignment operators: these operators are used to store/assign value to memory block
(var/array/objects...)
Operator is =
Shorthand/compound operator is a combination of assignment and arith/bitwise.
Operators are: += -= /= *= **= &= |= >>= <<= ...
Total=total+price total+=price
Concatenation operator: this operator is used to concatenation multiple strings then formed into a
single string. One operand should be string to perform concatenation. Resultant value comes in
string format.
Operator is +
unary operators: these operators are used to increment or to decrement a value. operators are ++
and --
++ (increment) ==> it adding 1 to an existing value Ex: a++ or ++a
-- (decrement) ==> it subtracting 1 from an existing value Ex: a-- or --a
101 | P a g e
ternary operator: this operator is used to decision making operation. operator is ?:, this operator
also called as conditional operator.
(condition) ? statement1 : statement2
Alert box: An alert box is often used if you want to make sure information comes through the user.
When an alert box pops up, the user will have to click "ok" to proceed.
Syn: window.alert("message"/expr);
ex:
<body>
<script type='text/javascript'>
alert("invalid entry");
</script>
</body>
Note:html tags we can’t use in alert() function.
confirm box:
It is often used, if you want the user to verify and accept something. When a confirm box pops up,
the user will have to click either "ok" or "cancel" to proceed. If the user clicks "ok" the box returns
“true”. If the user clicks "cancel" the box returns "false".
Syntax: window.confirm("message");
ex:
<head>
<script type='text/javascript'>
confirm("click ok or cancel");
</script>
</head>
ex:
<head>
<script type='text/javascript'>
var x=confirm("click ok or cancel");
alert("user selected option is:"+x);
</script>
</head>
ex:
<head>
<script type='text/javascript'>
var x=confirm("click ok or cancle");
alert("user selected option is:"+x);
if(x==true) {
alert("user clicked on OK button");
}
else{
alert("user clicked on cancel button");
}
</script>
</head>
104 | P a g e
}
</script>
</head>
<body>
<p> click the button to display the user selected result..</p>
<button onclick="myConfirm()">confirm</button>
</body>
Dynamic
While execute of program(after webpage open) assigning values to vars
This given by user
This always changing, means data changing the data execution to execution
We can take the data from user, in two ways:
Html input elements (UI/html forms)
Prompt dialog
Prompt Box: It is used to, if you want the user to input a value while entering a page. When a
prompt box pops up the user will have to click either "ok" or "cancel" to proceed after entering an
input value. If the user clicks "ok" the box returns the value/empty. If the user clicks "cancel" the
box returns "null".
Syntax: window.prompt("sometext", defaultvalue);
ex:
<head>
<script type='text/javascript'>
prompt("Enter Any Number:");
</script>
</head>
ex:
<head>
<script type='text/javascript'>
varMyVal=prompt("Enter Any Number:");
alert("User Entered value is:"+MyVal);
</script>
</head>
105 | P a g e
functionMyConfirm(){
confirm("click ok or cancel");
}
functionMyPrompt(){
prompt("Enter Any Value");
}
parseInt()
parseFloat()
predefine function => window
text based float converts into number-based float
“100" 100.0
"10.78" 10.78
"rama" NaN (Not a Numeric)
Syn:
window.parseFloat("value")
106 | P a g e
Control Statement
control statements are used to control(change) execution flow of program basedon user input data.
types:
> conditional statements (dm)
> loops (iterations)
> un-conditional
conditional (branching)
Conditional Statements:
If Statement
The if statement is used to perform decision making operations. means if condition is true, it
executes some statements. if condition is false, it executes some other statements.
If statement
if is most basic statement of Decision
Decision-making statements.nts. It tells to program to execute a certain
part of code only if particular condition or test case is true.
Example
<script>
var a=10;
if(a>5)
{
107 | P a g e
document.write("value of a is greater than 5");
}
</script>
if-else statement
In general, it can be used to execute one block of statement among two blocks.
108 | P a g e
Syntax
if(expression1)
{
//content to be evaluated if expression1 is true
}
else
if(expression2)
{
//content to be evaluated if expression2 is true
}
else
{
//content to be evaluated if no expression is true
}
Example of if..else if statement
<script>
var a=40;
if(a==20)
{
document.write("a is equal to 20");
}
else if(a==5)
{
document.write("a is equal to 5");
}
else if(a==30)
{
document.write("a is equal to 30");
109 | P a g e
}
else
{
document.write("a is not equal to 20, 5 or 30");
}
</script>
switch statement
> switch is selection statement, but it's not decision making.
> its better performance.
Syn:
switch(var/expr)
{
case value: statements...
break;
case value: statements...
break;
case ...
default: statements...
}
Looping Statement
Set of instructions given to the interpreter to execute until condition becomes false is called loops.
The basic purpose of loop is min code repetition.
The way of the repetition will be forming a circle that's why repetition statements are called loops.
Some loops are available In JavaScript which are given below.
while loop (top testing/entry level)
for loop
do-while (bottom testing/exit level)
while loop
When we are working with “while loop” always pre-checking process will be occurred. Pre-checking
process means before evolution of statement block condition part will be executed. “While loop”
will repeat in clock wise direction or anti-clock wise direction.
110 | P a g e
Example of while loop
<script>
var i=10;
while (i<=13)
{
document.write(i + "<br/>");
i++;
}
</script>
do-while loop
In implementation when we need to repeat the statement block at least 1 then go for do-while.
do In
do-while
while loop post checking of the statement block condition part will be executed.
111 | P a g e
Example of do-while loop
<script>
var i=11;
do{
document.write(i + "<br/>");
i++;
}while (i<=15);
</script>
for Loop
For loop is a simplest loop first we initialized the value then check condition and then increment and
decrements occurred.
112 | P a g e
Example of for loop
<script>
for (i=1; i<=5; i++)
{
document.write(i + "<br/>")
}
</script>
Unconditional statements
These are used to jump/skip statements execution
Types:
break
continue
return
<noscript> tag:: It is used to provide an alternate contains for users when script is disabled or not
supporting, It is a paired tag. It is always declared within the body section.
syntax: <noscript>------</noscript>
</noscript>
ex:
<head>
<script type='text/javascript'>
alert("welcome to js");
</script>
</head>
<body>
<noscript>
<p style='color:red'>oops your browser not supporting javascript
update/change the script settings and try..</p>
</noscript>
</body>
113 | P a g e
<!-- example on JS -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JS</title>
<!-- internal -->
<script type="text/javascript">
document.write("msg from head");
</script>
</head>
<body>
<!-- inline -->
<h1 ondblclick="alert('button clicked')">click here</h1>
<button onclick="alert('button pressed')">press here</button>
<br>
<script type="text/javascript">
document.write("msg from body");
</script>
</body>
</html>
</body>
</html>
<script>
document.write("Hello World");
document.writeln("Welcome");
console.log("invalid connection");
</script>
114 | P a g e
<!-- example on JS
1. JS produces error, error msg are displaying in console
2. in JS string/text we can rep with either " " or ' ' or ` `
115 | P a g e
<!-- example on JS -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JS</title>
</head>
<body>
<h3>demo on html in js</h3>
<script>
//<h2>Welcome</h2> error
document.write("<h2>Welcome</h2>");
document.write(`<h2>Hello</h2>`);
document.write("<h2 align='center'>JavaScript</h2>");
document.write(`<input type="text" id="t1" name="t1"/>`);
</script>
</body>
</html>
let c; //dec
c=101;
let d=202; //init
document.write(c,'<br>');
document.write(d+'<br>');
</script>
</body>
</html>
116 | P a g e
<!-- example on JS -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JS</title>
</head>
<body>
<h3>demo on const</h3>
<script>
var a=10; //init
let b=20; //init
document.write(a,'<br>');
document.write(b+'<br>');
a=11; //modify -> valid
b=22;
document.write(a,'<br>');
document.write(b+'<br>');
</body>
</html>
117 | P a g e
document.write(a,` => `,typeof a, `<br>`);
document.write(b + ` => `+ typeof b + `<br>`);
document.write(c,` => `,typeof c, `<br>`);
document.write(d,` => `,typeof d, `<br>`);
document.write(e,` => `,typeof e, `<br>`);
document.write(f,` => `,typeof f, `<br>`);
document.write(g,` => `,typeof g, `<br>`);
</script>
</body>
</html>
118 | P a g e
</body>
</html>
//We can use a variable directly without declaring it in javascript, it’s called "dynamic"
programming.
x=100;
document.write( x,"<br>");
z="ram";
document.write( z,"<br>");
document.write( window.x, window.z, window.y );
</script>
</body>
</html>
119 | P a g e
<div class="header-left">India's No.1 Software Training Institute</div>
<div class="header-right">Hyderabad | Chennai | USA | Online Training</div>
</div>
<br>
<div>
<img src="images/nit.png"/>
<h1 class="nit-heading">Naresh i Tech</h1>
</div>
</header>
<br>
<!-- menu bar -->
<nav id="menu-bar">
<a href="home.html" class="menu-item" target="myframe"> <img
src="images/home.png" width="15px" height="15px"/>Home</a>
<a href="service.html" target="myframe" class="menu-item">Services</a>
<a href="course.html" target="myframe" class="menu-item">Courses<a/>
<a href="batches.html" target="myframe" class="menu-item">New Batches<a/>
<a href="contact.html" target="myframe" class="menu-item">Contact Us<a/>
</nav>
<br>
<!-- content displaying -->
<section id="section">
<iframe name="myframe" src="images/jfs.jpg" frameborder width="100%"
height="100%"> </iframe>
</section>
<!-- footer content -->
<footer id="footer">
</footer>
</body>
</html>
120 | P a g e
color:red;
font-size:18px;
}
a{
color:#3300cc;
text-decoration:none;
}
a:hover{
color:#cc0000;
text-decoration:underline;
}
#button{
background:linear-gradient(to top, red, blue);
color:white;
width:170px;
height:30px;
font-size:22px;
border:none;
border-radius:15px;
}
#button:hover{
background:linear-gradient(to bottom, red, blue);
}
body{
background-image:url(images/wall.webp);
background-size:100% auto;
}
//relational
document.write( x>=y,`<br>`);
121 | P a g e
let z="8";
document.write( y==z, `<br>`);
document.write( y===z, `<br>`);
document.write( y!=z, `<br>`);
document.write( y!==z, `<br>`);
//logical
document.write( y>=1 && y<=10, `<br>`);
document.write( x==20 || x==30, `<br>`);
//concate
document.write("rama"+"rao"+"<br>");
document.write("X val is "+x+"<br>");
//unary
x++; //post incre
document.write(x+`<br>`);
++x; //pre incre
document.write(x+`<br>`);
y--; //post decre
document.write(y+`<br>`);
--y; //pre decre
document.write(y+`<br>`);
//conditional
document.write( y%2===0 ? "Even number" : "Odd number" );
</script>
</body>
</html>
122 | P a g e
let x = window.confirm('do you want to exit?');
document.write(x+`<br>`);
</body>
</html>
<script>
123 | P a g e
function addition()
{
let x = parseInt(tf1.value);
let y = parseInt(tf2.value);
let res = x+y;
//document.write(`Sum is `+res);
//console.log(`Sum is `+res);
alert(`Sum is `+res);
}
</script>
</body>
</html>
124 | P a g e
background:#00ffff;
padding:20px;
}
input{
border:none;
outline:none;
background:#00ffff;
border-bottom:2px solid black;
}
</style>
</head>
<body>
<div>
<h3 align="center"><u>Simple Interest Calc</u></h3>
<p>
<label>Principal Amount</label> <br>
<input type="text" id="pamt"/> <span>₹</span>
</p>
<p>
<label>Rate of Interest</label> <br>
<input type="text" id="roi"/> <span>%</span>
</p>
<p>
<label>Time</label> <br>
<input type="text" id="time"/> <span>Year(s)</span>
</p>
<button onclick="compute()">Calculate</button>
<br>
<output id="res"></output>
</div>
<script>
function compute()
{
let p, r, t, si; //local vars
p = pamt.value;
r = roi.value;
t = time.value;
si = p*t*r/100;
//alert(`Simple Interest Amount :Rs`+si);
res.value = `Simple Interest Amount :Rs`+si;
}
</script>
</body>
</html>
<!--
DOM ==> API => lib => coll of classes
125 | P a g e
==> interface b/w html page & js
==> dynamic accessing data, updating data, changing structure and to change stlye of web
page
==> tree structure
==> dom objects are created by browser while loading web page
window
document console nav
getElementById()
get instance of an Element By using Id attri
getElementsByName()
get instances of an Element By using Name attri
getElementsByTagName()
get instances of an Element By using Tag Name
querySelector()
get instance of an Element By using selector name
querySelectorAll()
get instances of an Element By using selector name
126 | P a g e
<script>
let h = document.getElementById("head1");
document.write(h,"<br>");
let ob = document.getElementsByName("head2");
document.write(ob);
<!--
DOM ==> API => lib => coll of classes
==> interface b/w html page & js
==> dynamic accessing data, updating data, changing structure and to change stlye of web
page
==> tree structure
==> dom objects are created by browser while loading web page
window
document console nav
getElementById()
get instance of an Element By using Id attri
getElementsByName()
get instances of an Element By using Name attri
getElementsByTagName()
get instances of an Element By using Tag Name
querySelector()
get instance of an Element By using selector name
querySelectorAll()
get instances of an Element By using selector name
127 | P a g e
document object mehtods
-->
<!-- example on DOM -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Dom</title>
</head>
<body>
<h1 id="head1">Apple</h1>
<h1 id="head1">Banana</h1>
<h2 class="head2">Mango</h2>
<h3 class="head2">Orange</h3>
<script>
let ob1 = document.querySelector("#head1");
document.write(ob1,"<br>");
let h2 = document.getElementById("head2");
//h2.innerText+=" <u>World</u>"; OR
128 | P a g e
h2.innerHTML+=" <u>World</u>";
</script>
</body>
</html>
2nd approch:
1 get element object
2. attach event to object
Syn:- ele-obj.event-name = task;
event-name => onclick, onload, onfocus, onblur ...
task => function expr or fun
<tag event="fun/step">
129 | P a g e
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Dom</title>
<script>
function fun1()
{
alert("button clicked");
}
function fun2()
{
alert("button pressed");
}
</script>
</head>
<body>
<button id="bt1">Click here</button>
<button id="bt2">Press here</button>
<script>
//1st approch
const b1=document.getElementById("bt1");
b1.addEventListener("click", fun1 );
//OR
//document.getElementById("bt1").addEventListener("click", fun1);
//2nd approch
const b2=document.getElementById("bt2");
b2.onclick=fun2;
//OR
//document.getElementById("bt2").onclick=fun2;
</script>
</body>
</html>
130 | P a g e
<script>
document.getElementById("bt").onclick=function(){
let x=+document.getElementById("tb1").value;
let y=+document.getElementById("tb2").value;
let s=x+y;
document.querySelector("#result").innerText=`Sum is `+s;
</script>
</body>
</html>
//changin style
document.querySelector(".c2").onclick=function(){
const h=document.getElementById("head1");
//ele-obj.style.css-prop=value;
h.style.color="red";
h.style.backgroundColor="#ffff00";
};
</script>
</body>
</html>
131 | P a g e
<body>
<h1 id="heading">Siva Kumar Y</h1>
<input type="radio" id="color1" name="color"/> <label>Red</label>
<input type="radio" id="color2" name="color"/> <label>Blue</label>
<input type="radio" id="color3" name="color"/><label>Green</label>
<input type="radio" id="color4" name="color"/> <label>Pink</label>
<script>
//when selects 1st radio button
document.querySelector("#color1").onchange=function(){
document.getElementById("heading").style.color="red";
};
//when selects 2nd radio button
document.querySelector("#color2").onchange=function(){
document.getElementById("heading").style.color="blue";
};
//when selects 3rd radio button
document.querySelector("#color3").onchange=function(){
document.getElementById("heading").style.color="green";
};
//when selects 4th radio button
document.querySelector("#color4").onchange=function(){
document.getElementById("heading").style.color="#ff00ff";
};
</script>
</body>
</html>
<script>
//when user change color
const c = document.querySelector("#col");
c.onchange=function(){
document.getElementById("heading").style.backgroundColor=c.value;
};
132 | P a g e
</script>
</body>
</html>
img{
width:200px;
height:250px;
margin:50px;
}
</style>
</head>
<body>
<div align="center">
<img src="images/dress1_a.webp" id="img1"/>
<img src="images/dress2_a.webp" id="img2"/>
<img src="images/dress3_a.webp" id="img3"/>
</div>
<script>
//img1 object
const im1=document.getElementById("img1");
//mouse comes on to img1
im1.onmouseover=function(){im1.src="images/dress1_b.webp";};
//mouse comes out from img1
im1.onmouseout=function(){im1.src="images/dress1_a.webp";};
//img2 object
const im2=document.getElementById("img2");
//mouse comes on to img2
im2.onmouseover=function(){im2.src="images/dress2_b.webp";};
//mouse comes out from img2
im2.onmouseout=function(){im2.src="images/dress2_a.webp";};
//img3 object
const im3=document.getElementById("img3");
//mouse comes on to img3
im3.onmouseover=function(){im3.src="images/dress3_b.webp";};
//mouse comes out from img3
im3.onmouseout=function(){im3.src="images/dress3_a.webp";};
</script>
</body>
133 | P a g e
</html>
</script>
</body>
</html>
134 | P a g e
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JS</title>
</head>
<body>
<h3>demo on if else </h3>
<script>
//finding biggest value of 2numbers
let x = +prompt("enter first number");
let y = +prompt("enter second number");
if(x>y)
document.write("First number is big");
else if(y>x)
document.write("Second number is big");
else
document.write("No one is big");
</script>
</body>
</html>
135 | P a g e
break;
default: document.write("Invalid Day");
}
</script>
</body>
</html>
</script>
</body>
</html>
</script>
</body>
</html>
136 | P a g e
<!-- example on conditional statements -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JS</title>
</head>
<body>
<h3>demo on loops</h3>
<script>
let i=1;
do
{
document.write(i+" ");
i++;
}while(i<=10);
</script>
</body>
</html>
137 | P a g e
document.getElementById("result").innerHTML=st;
};
</script>
</body>
</html>
<!--
Arrays
------
==> array is ref variable
==> arra is coll of elements
==> it allows same type of values & different types of values
==> storing no.of values with a same refname is called array
Adv ==> simple coding while working no.of values
==> data maintain
==> easy transporting data
==> JS arrays are dynamic
==> Heap area
2nd Approch:
by using new keyword
Syn:- refvar = new Array();
accessing:
refvar[index]
138 | P a g e
index => slno for memory block, index starts with 0
data assigning:
refvar[index]=value;
</body>
</html>
139 | P a g e
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JS</title>
</head>
<body>
<h3>demo on arrays</h3>
<script>
//2nd Approch
let a = new Array(); //array declaration
document.write(`Size :`+ a.length +`<br>`);
document.write(`A :`+ a +`<br>`);
a[0]=10; //assigning
a[1]=22;
a[2]=34;
document.write(`Size :`+ a.length +`<br>`);
document.write(`A :`+ a +`<br>`);
</script>
</body>
</html>
140 | P a g e
//resizing array
let c=[11,22,33,44,55,66,77,88];
document.write(`<br>Size `+c.length);
document.write(`<br>Elements :`+c);
c.length=5; //reduced size
document.write(`<br>Size `+c.length);
document.write(`<br>Elements :`+c);
//c.length=7; optional
c[5]=10;
c[6]=20;
document.write(`<br>Size `+c.length);
document.write(`<br>Elements :`+c);
</script>
</body>
</html>
if(a[i]<min)
min=a[i];
}
document.write(`Elements :`+a+`<br>`);
document.write(`Max Ele :`+max+`<br>`);
document.write(`Min Ele :`+min+`<br>`);
</script>
141 | P a g e
</body>
</html>
document.write(a+"<br>");
document.write(a.length+"<br>");
document.write(a[0].length+"<br><br>");
</script>
</body>
</html>
142 | P a g e
for(let i=0; i<a.length; i++)
{
for(let j=0; j<a[i].length; j++) {
document.write(a[i][j]+" ");
}
document.write("<br>");
}
</script>
</body>
</html>
<script>
let imgs=["xuv1.webp", "xuv2.jpg", "xuv3.webp", "xuv4.webp","xuv5.webp","xuv6.webp"];
let index=0;
//next image logic
document.getElementById("nb").onclick=function(){
if(index>=imgs.length)
index=5;
143 | P a g e
document.getElementById("image").src="images/"+imgs[index];
index++;
};
document.getElementById("pb").onclick=function(){
if(index<0)
index=0;
document.getElementById("image").src="images/"+imgs[index];
index--;
};
</script>
</body>
</html>
144 | P a g e