3. ā¢ Image Format describes how data related to
the image will be stored.
ā¢ Data can be stored in compressed,
Uncompressed or vector format.
ā¢ Each format of the image have a different
advantage and disadvantage.
ā¢ Image types such a TIFF are good for printing
while JPG or PNG, are best for web.
4. ā¢ JPEG (.jpg, .jpeg)
Joint Photographic Experts Group is a loss-prone (lossy)
format in which data is lost to reduce size of image.
Due to compression, some data is lost but that loss is
very less. It is a very common format and are good for
digital cameras, nonprofessional prints, E-Mail,
Powerpoint etc., making it ideal for web use.
ā¢ GIF (.gif)
GIF or Graphics Interchange Format files are used for
web graphics.They can be animated and are limited to
only 256 colors, can allow for transparency. GIF files
are typically small is size and are portable.
ā¢ PNG (.png)
PNG or Portable Network Graphics files are a lossless
image format. It was designed to replace gif format as
gif supported 256 colors unlike PNG which support 16
million colors.
5. Difference between Server Side
Scripting and Client Side Scripting
ā¢ 1. Client side scripting :
web browsers execute client side scripting. It is use when
browsers has all code.
ā¢ Source code used to transfer from web server to userās
computer over internet and run directly on browsers. It is
also used for validations and functionality for user events.
ā¢ It allows for more interactivity.
ā¢ It usually performs several actions without going to user.
ā¢ It cannot be basically used to connect to databases on web
server.
ā¢ Pages are altered on basis of users choice. It can also used
to create ācookiesā that store data on userās computer
8. ā¢ 2. Server side scripting :
Web servers are used to execute server side scripting.
They are basically used to create dynamic pages.
ā¢ It can also access the file system residing at web server.
Server-side environment that runs on a scripting
language is a web-server.
ā¢ Scripts can be written in any of a number of server-side
scripting language available.
ā¢ It is used to retrieve and generate content for dynamic
pages. A dynamic page displays different content for
different users while retaining the same layout and
design
ā¢ It is used to require to download plugins. In this load
times are generally faster than client-side scripting.
When you need to store and retrieve information a
database will be used to contain data. It can use huge
resources of server.
ā¢ It reduces client-side computation overhead. Server
sends pages to request of user/client.
9. For example in a social media site, if you request info about @myFriend
the server will look up that user and return his profile if found.
10.
11. What is JavaScript
ā¢ JavaScript (js) is a light-weight object-oriented
programming language which is used by several
websites for scripting the webpages.
ā¢ It is an interpreted, full-fledged programming
language that enables dynamic interactivity on
websites when applied to an HTML document.
ā¢ It was introduced in the year 1995 for adding
programs to the webpages in the Netscape
Navigator browser.
ā¢ Since then, it has been adopted by all other
graphical web browsers. A process is said to be lightweight if it occupies
less Memory and takes less processor time to
complete.
14. JavaScript Example
The write() method in HTML is used to write some
content or JavaScript code in a Document. This method
is mostly used for testing purpose.
15. JavaScript Example
ā¢ Javascript example is easy to code.
ā¢ JavaScript provides 3 places to put the
JavaScript code: within body tag, within head
tag and external JavaScript file.
ā¢ Letās create the first JavaScript example.
16. ā¢ The text/javascript is the content type that
provides information to the browser about the
data.
ā¢ The document.write() function is used to
display dynamic content through JavaScript.
We will learn about document object in detail
later.
17. 3 Places to put JavaScript code
1. Between the body tag of html
2. Between the head tag of html
3. In .js file (external javaScript)
18. 1) JavaScript Example : code between
the body tag
ā¢ In the above example, we have displayed the
dynamic content using JavaScript.
ā¢ Letās see the simple example of JavaScript that
displays alert dialog box
19.
20.
21. 2) JavaScript Example : code between
the head tag
ā¢ Letās see the same example of displaying alert
dialog box of JavaScript that is contained
inside the head tag.
ā¢ In this example, we are creating a function
msg().
ā¢ To create function in JavaScript, you need to
write function with function_name as given
below.
ā¢ To call function, you need to work on event.
Here we are using onclick event to call msg()
function.
25. 3. External JavaScript file
ā¢ We can create external JavaScript file and
embed it in many html page.
ā¢ It provides code re usability because single
JavaScript file can be used in several html
pages.
ā¢ An external JavaScript file must be saved by .js
extension. It is recommended to embed all
JavaScript files into a single file. It increases
the speed of the webpage.
26. ā¢ Let's create an external JavaScript file that
prints Hello Javatpoint in a alert dialog box.
message.js
function msg(){
alert("Hello JavatScript");
}
ā¢ Let's include the JavaScript file into html page.
ā¢ It calls the JavaScript function on button click.
27.
28.
29.
30.
31. JavaScript String replace() Method
ā¢ The JavaScript string replace() method is used
to replace a part of a given string with a new
substring.
ā¢ This method searches for specified regular
expression in a given string and then replace it
if the match occurs.
ā¢ We can use global search modifier with
replace() method to replace all the match
elements otherwise the method replace only
first match. JavaScript also provides ignore flag
to make the method case-insensitive.
32.
33. Parameter
ā¢ originalstr - It represents the string to be
searched and replaced.
ā¢ Newstr - It represents the new string that
replaced with the searched string.
34.
35.
36.
37. JavaScript String charAt() Method
ā¢ The JavaScript string charAt() method is used
to find out a char value present at the
specified index in a string.
ā¢ The index number starts from 0 and goes to n-
1, where n is the length of the string.
ā¢ The index value can't be a negative, greater
than or equal to the length of the string.
42. JavaScript Math abs() method
ā¢ The JavaScript math abs() method returns an
absolute value of a given number.
ā¢ The abs() is a static method of Math.
48. JavaScript Date getDate() method
ā¢ The JavaScript date getDate() method returns
the day for the specified date on the basis of
local time.
49.
50.
51. Difference between var and let in
JavaScript
ā¢ var and let are both used for variable
declaration in javascript but the difference
between them is that var is function scoped
and let is block scoped.
It can be said that a variable declared with var
is defined throughout the program as
compared to let.
55. Javascript Data Types
ā¢ JavaScript provides different data types to
hold different types of values.
ā¢ There are two types of data types in
JavaScript.
1. Primitive data type
2. Non-primitive (reference) data type
56. ā¢ JavaScript is a dynamic type language, means
you don't need to specify type of the variable
because it is dynamically used by JavaScript
engine.
ā¢ You need to use var here to specify the data
type.
ā¢ It can hold any type of values such as
numbers, strings etc.
ā¢ For example:
57. JavaScript primitive data types
ā¢ There are five types of primitive data types in
JavaScript.
ā¢ They are as follows:
70. JavaScript Arithmetic Operators
ā¢ Arithmetic operators are used to perform
arithmetic operations on the operands.
ā¢ The following operators are known as
JavaScript arithmetic operators.
71.
72. JavaScript Comparison Operators
ā¢ The JavaScript comparison operator compares
the two operands.
ā¢ The comparison operators are as follows:
73.
74.
75. JavaScript Bitwise Operators
ā¢ The bitwise operators perform bitwise
operations on operands.
ā¢ The bitwise operators are as follows:
98. JavaScript Loops
ā¢ The JavaScript loops are used to iterate the
piece of code using for, while, do while or for-
in loops.
ā¢ It makes the code compact.
ā¢ It is mostly used in array.
ā¢ There are four types of loops in JavaScript.
1. for loop
2. while loop
3. do-while loop
4. for-in loop
99. 1) JavaScript For loop
ā¢ The JavaScript for loop iterates the elements
for the fixed number of times.
ā¢ It should be used if number of iteration is
known.
ā¢ The syntax of for loop is given below.
102. 2) JavaScript while loop
ā¢ The JavaScript while loop iterates the
elements for the infinite number of times.
ā¢ It should be used if number of iteration is not
known.
ā¢ The syntax of while loop is given below.
103. Letās see the simple example of while
loop in javascript.
104.
105. 3) JavaScript do while loop
ā¢ The JavaScript do while loop iterates the
elements for the infinite number of times like
while loop.
ā¢ But, code is executed at least once whether
condition is true or false.
ā¢ The syntax of do while loop is given below.
106. Letās see the simple example of do
while loop in javascript.
107.
108. 4) JavaScript for in loop
ā¢ The JavaScript for in loop is used to iterate the
properties of an object.
109.
110.
111. JavaScript Functions
ā¢ JavaScript functions are used to perform
operations.
ā¢ We can call JavaScript function many times to
reuse the code.
ā¢ Advantage of JavaScript function
ā¢ There are mainly two advantages of JavaScript
functions.
ā¢ Code reusability:
ā¢ We can call a function several times so it save
coding.
ā¢ Less coding:
ā¢ It makes our program compact.
ā¢ We donāt need to write many lines of code each
time to perform a common task.
112.
113. ā¢ where, function_name represents the name
of the function and parameter-1, ... ,
parameter-n represents list of parameters.
114. JavaScript Function Syntax
ā¢ The syntax of declaring function is given
below.
JavaScript Functions can have 0 or more arguments.
119. JavaScript Function Arguments
ā¢ We can call function by passing arguments.
Letās see the example of function that has one
argument.
120.
121.
122.
123. Function with Return Value
ā¢ We can call function that returns a value and
use it in our program.
ā¢ Letās see the example of function that returns
value.
124.
125.
126. Using Iterative approach
ā¢ Here, we are iterating a loop over the
sequence of numbers to get the factorial of a
given number.
ā¢ Using this approach, the consumption of
memory is less than the recursive
implementation.
ā¢ But the code is lengthier than the recursive
method.
127. Example
ā¢ In this example, there is a text field that
requires a number and a button, which gives
us the factorial of the entered number.
ā¢ We have to enter a number in the given
textfield to find the factorial of that number.
ā¢ Then we need to click the given button
named Factorial to get the result.
ā¢ If we enter a negative number, then the
program calculates the factorial of 0, which
is 1.
132. Using Recursive approach
ā¢ In this approach, we are using recursion to
calculate the factorial of a number.
ā¢ Here, we call same function again and again to
get the factorial. Using recursion, we have to
code less than the iterative approach.
ā¢ Now, we will see an example of finding the
factorial of number using recursion in
JavaScript.
133. Example
ā¢ Here there is a function fact(), which accepts a
parameter num. It is a number for which we
need to calculate the factorial.
ā¢ The function returns 1 when the value
of num is 0.
ā¢ In the output we will see a text field that
requires number and a button which gives us
the factorial of the entered number.
ā¢ We have to enter a number in the given
textfield to find the factorial of that number.
Then we need to click the given button named
as Factorial to get the result.
134.
135.
136.
137.
138.
139.
140.
141.
142. JavaScript Objects
ā¢ A javaScript object is an entity having state
and behavior (properties and method).
ā¢ For example: car, pen, bike, chair, glass,
keyboard, monitor etc.
ā¢ JavaScript is an object-based language.
Everything is an object in JavaScript.
ā¢ JavaScript is template based not class based.
Here, we don't create class to get the object.
But, we direct create objects.
143.
144.
145. Creating Objects in JavaScript
ā¢ There are 3 ways to create objects.
1. By object literal
2. By creating instance of Object directly (using
new keyword)
3. By using an object constructor (using new
keyword)
146. 1) JavaScript Object by object literal
ā¢ The syntax of creating object using object
literal is given below:
As you can see, property and value is separated by : (colon).
147.
148.
149. 2) By creating instance of Object
ā¢ The syntax of creating object directly is given
below:
150.
151.
152. 3) By using an Object constructor
ā¢ Here, you need to create function with
arguments.
ā¢ Each argument value can be assigned in the
current object by using this keyword.
ā¢ The this keyword refers to the current object.
ā¢ The example of creating object by object
constructor is given below.
153.
154.
155. Defining method in JavaScript Object
ā¢ We can define method in JavaScript object.
But before defining method, we need to add
property in the function with same name as
method.
ā¢ The example of defining method in object is
given below.
156.
157.
158. JavaScript Array
ā¢ JavaScript array is an object that represents a
collection of similar type of elements.
ā¢ There are 3 ways to construct array in
JavaScript
1. By array literal
2. By creating instance of Array directly (using
new keyword)
3. By using an Array constructor (using new
keyword)
159. 1) JavaScript array literal
ā¢ The syntax of creating array using array literal
is given below:
As you can see, values are contained inside [ ] and
separated by , (comma).
Note: Literals are constant values that can be assigned to the
variables
160. ā¢ Let's see the simple example of creating and
using array in JavaScript
162. 2) JavaScript Array directly (new
keyword)
ā¢ The syntax of creating array directly is given
below:
ā¢ Here, new keyword is used to create instance
of array.
165. 3) JavaScript array constructor (new
keyword)
ā¢ Here, you need to create instance of array by
passing arguments in constructor so that we
don't have to provide value explicitly.
166. The example of creating object by
array constructor is given below.
168. Array Methods
ā¢ The following table lists the standard methods
of the Array object.
169.
170.
171.
172.
173.
174.
175.
176.
177.
178.
179.
180.
181.
182.
183.
184.
185.
186. JavaScript Built-in Objects
ā¢ Built-in Objects
ā¢ Built-in objects are not related to any Window
or DOM object model.
ā¢ These objects are used for simple data
processing in the JavaScript.
203. JavaScript Events
ā¢ The change in the state of an object is known as
an Event.
ā¢ In html, there are various events which represents that
some activity is performed by the user or by the
browser.
ā¢ When javascript code is included in HTML, js react over
these events and allow the execution. This process of
reacting over the events is called Event Handling.
ā¢ Thus, js handles the HTML events via Event Handlers.
ā¢ For example, when a user clicks over the browser, add
js code, which will execute the task to be performed on
the event.
ā¢ Some of the HTML events and their event handlers are:
229. JavaScript addEventListener()
ā¢ The addEventListener() method is used to attach
an event handler to a particular element.
ā¢ It does not override the existing event handlers.
Events are said to be an essential part of the
JavaScript.
ā¢ A web page responds according to the event that
occurred.
ā¢ Events can be user-generated or generated by
API's. An event listener is a JavaScript's procedure
that waits for the occurrence of an event.
ā¢ The addEventListener() method is an inbuilt
function of JavaScript. We can add multiple event
handlers to a particular element without
overwriting the existing event handlers.
232. Example
ā¢ It is a simple example of using the
addEventListener() method.
ā¢ We have to click the given HTML button to see
the effect.
233.
234.
235.
236. ā¢ Now, in the next example we will see how to
add many events to the same element
without overwriting the existing events.
237.
238.
239.
240.
241. Example
ā¢ In this example, we are adding multiple events
of a different type to the same element.
242.
243.
244.
245.
246. Using JavaScript
ā¢ In this example, we are using
JavaScript's onclick event.
ā¢ Here we are using the onclick event with the
paragraph element.
ā¢ When the user clicks on
the paragraph element, the corresponding
function will get executed, and the text of the
paragraph gets changed.
ā¢ On clicking the <p> element, the background
color, size, border, and color of the text will
also get change.
247.
248.
249.
250. Using addEventListener() method
ā¢ In this example, we are using
JavaScript's addEventListener() method to
attach a click event to the paragraph element.
ā¢ When the user clicks the paragraph element,
the text of the paragraph gets changed.
ā¢ On clicking the paragraph, the background
color and font-size of elements will also
change.
251.
252.
253.
254. Window Object
ā¢ The window object represents a window in
browser.
ā¢ An object of window is created automatically
by the browser.
ā¢ Window is the object of browser, it is not the
object of javascript.
ā¢ The javascript objects are string, array, date
etc.
256. Example of alert() in javascript
ā¢ It displays alert dialog box.
ā¢ It has message and ok button.
257.
258.
259. Example of confirm() in javascript
ā¢ It displays the confirm dialog box.
ā¢ It has message with ok and cancel buttons.
260.
261.
262.
263. Example of prompt() in javascript
ā¢ It displays prompt dialog box for input.
ā¢ It has message and textfield.
264.
265.
266.
267.
268. Example of open() in javascript
ā¢ It displays the content in a new window.
269.
270.
271.
272. Example of setTimeout() in javascript
ā¢ It performs its task after the given
milliseconds.
273.
274.
275. What is CSS
ā¢ CSS stands for Cascading Style Sheets.
ā¢ It is a style sheet language which is used to
describe the look and formatting of a document
written in markup language.
ā¢ It provides an additional feature to HTML.
ā¢ It is generally used with HTML to change the
style of web pages and user interfaces.
ā¢ It can also be used with any kind of XML
documents including plain XML, SVG and XUL.
ā¢ CSS is used along with HTML and JavaScript in
most websites to create user interfaces for web
applications and user interfaces for many mobile
applications.
276. ā¢ The major points of CSS are given below:
ā¢ CSS stands for Cascading Style Sheet.
ā¢ CSS is used to design HTML tags.
ā¢ CSS is a widely used language on the web.
ā¢ HTML, CSS and JavaScript are used for web
designing.
ā¢ It helps the web designers to apply style on
HTML tags.
279. CSS Syntax
ā¢ A CSS rule set contains a selector and a
declaration block.
280. ā¢ Selector:
ā¢ Selector indicates the HTML element you want
to style.
ā¢ It could be any tag like <h1>, <title> etc.
ā¢ Declaration Block:
ā¢ The declaration block can contain one or more
declarations separated by a semicolon.
ā¢ For the above example, there are two
declarations:
ā¢ color: yellow;
ā¢ font-size: 11 px;
281. ā¢ Each declaration contains a property name
and value, separated by a colon.
Property:
ā¢ A Property is a type of attribute of HTML
element.
ā¢ It could be color, border etc.
Value:
ā¢ Values are assigned to CSS properties.
ā¢ In the above example, value "yellow" is
assigned to color property.
282. CSS Selector
ā¢ CSS selectors are used to select the content
you want to style.
ā¢ Selectors are the part of CSS rule set.
ā¢ CSS selectors select HTML elements according
to its id, class, type, attribute etc.
283. ā¢ There are several different types of selectors
in CSS.
1. CSS Element Selector
2. CSS Id Selector
3. CSS Class Selector
4. CSS Universal Selector
5. CSS Group Selector
284. 1) CSS Element Selector
ā¢ The element selector selects the HTML
element by name.
285.
286.
287. 2) CSS Id Selector
ā¢ The id selector selects the id attribute of an
HTML element to select a specific element.
ā¢ An id is always unique within the page so it is
chosen to select a single, unique element.
ā¢ It is written with the hash character (#),
followed by the id of the element.
ā¢ Let?s take an example with the id "para1".
288.
289.
290. 3) CSS Class Selector
ā¢ The class selector selects HTML elements with
a specific class attribute.
ā¢ It is used with a period character .
(full stop symbol) followed by the class name.
291.
292.
293. CSS Class Selector for specific element
ā¢ If you want to specify that only one specific
HTML element should be affected then you
should use the element name with class
selector.
ā¢ Let's see an example.
294.
295.
296. 4) CSS Universal Selector
ā¢ The universal selector is used as a wildcard
character.
ā¢ It selects all the elements on the pages.
297.
298.
299. 5) CSS Group Selector
ā¢ The grouping selector is used to select all the
elements with the same style definitions.
ā¢ Grouping selector is used to minimize the
code. Commas are used to separate each
selector in grouping.
ā¢ Let's see the CSS code without group selector.
300.
301. ā¢ As you can see, you need to define CSS
properties for all the elements.
ā¢ It can be grouped in following ways:
302.
303.
304. How to add CSS
ā¢ CSS is added to HTML pages to format the
document according to information in the
style sheet.
ā¢ There are three ways to insert CSS in HTML
documents.
1. Inline CSS
2. Internal CSS
3. External CSS
305. 1) Inline CSS
ā¢ Inline CSS is used to apply CSS on a single line
or element.
306. ā¢ Inline CSS: Inline CSS contains the CSS
property in the body section attached with
element is known as inline CSS.
ā¢ This kind of style is specified within an HTML
tag using the style attribute.
311. Disadvantages of Inline CSS
ā¢ You cannot use quotations within inline CSS.
ā¢ If you use quotations the browser will
interpret this as an end of your style value.
ā¢ These styles cannot be reused anywhere else.
ā¢ These styles are tough to be edited because
they are not stored at a single place.
ā¢ It is not possible to style pseudo-codes and
pseudo-classes with inline CSS.
ā¢ Inline CSS does not provide browser cache
advantages.
312. 2) Internal CSS
ā¢ Internal CSS is used to apply CSS on a single
document or page.
ā¢ It can affect all the elements of the page.
ā¢ It is written inside the style tag within head
section of html.
ā¢ For example:
313. ā¢ Internal or Embedded CSS:
ā¢ This can be used when a single HTML
document must be styled uniquely.
ā¢ The CSS rule set should be within the HTML
file in the head section i.e the CSS is
embedded within the HTML file.
318. 3) External CSS
ā¢ External CSS is used to apply CSS on multiple
pages or all pages.
ā¢ Here, we write all the CSS code in a css file.
ā¢ Its extension must be .css for example
style.css.
319.
320. ā¢ External CSS:
ā¢ External CSS contains separate CSS file which
contains only style property with the help of
tag attributes (For example class, id, heading,
ā¦ etc).
ā¢ CSS property written in a separate file with
.css extension and should be linked to the
HTML document using link tag.
ā¢ This means that for each element, style can be
set only once and that will be applied across
web pages.
348. Advantages of CSS
ā¢ Saves time: It allows you define a style for
each HTML element. You can apply this style
to as many web pages as you want.
ā¢ Easy maintenance: You can easily update
document formatting and maintain
consistency in multiple documents.
ā¢ Faster page loading: It allows multiple pages
to share formatting that reduces file transfer
size which helps pages load faster.
349. ā¢ Platform Independence:
ā¢ It offers platform independence and also
supports the latest browsers.
ā¢ Multiple device compatibility:
ā¢ It allows you optimize content for more than
one type of devices.
ā¢ You can present a HTML document in
different viewing styles for different devices
like computer, cell phone and printer.
350. Superior styles to HTML:
It has more presentation capabilities than HTML.
It allows you enhance the look of your HTML
pages better than using HTML presentational
elements and attributes.