0% found this document useful (0 votes)
17 views125 pages

Web Design Internship Report

The document is a report by Oshan Manhas on a MOOC project focused on CSS and JavaScript, submitted to the Computer Engineering Department at the University of Jammu. It acknowledges the support received during the course and outlines the objectives of the internship, which included learning website design and various programming languages like HTML, CSS, and JavaScript. The report emphasizes the importance of web-based applications and the practical experiences gained during the training.

Uploaded by

oshanmanhas
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views125 pages

Web Design Internship Report

The document is a report by Oshan Manhas on a MOOC project focused on CSS and JavaScript, submitted to the Computer Engineering Department at the University of Jammu. It acknowledges the support received during the course and outlines the objectives of the internship, which included learning website design and various programming languages like HTML, CSS, and JavaScript. The report emphasizes the importance of web-based applications and the practical experiences gained during the training.

Uploaded by

oshanmanhas
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

UNIVERSITY OF JAMMU

MOOC PROJECT /
REPORT FILE
ON
CSS & JavaScript
NAME :OSHAN MANHAS
ROLLNO : 221103032
BRANCH :COMPUTER ENGINEERING
SEMESTER :3rd

Submitted to :
HOD
Computer Engineering Department

Dept. of Computer Engineering


ACKNOWLEDGEMENT

An endeavor over a long period can be successful only with the advices and support of
many well wishers. I take this opportunity to express my gratitude and appreciation to all
who helped me to complete my course.
First of all I express my gratitude and indebtness to Udemy – Online Courses for their
keen intrest and timely suggestions by which it has been possible for me to complete my
course well with in limited period of time.
I am very grateful to respected principal of G.C.E.T Dr. Sameru Sharma , [Link] Dutta
H.O.D of Computer Department for granting me permission to fulfill my course.
Lat but not the least I’m thankful to my parents and friends who emboldened me when I
was in despair, without their patronization this work would not have been viable.

Submitted by
OSHAN MANHAS

Dept. of Computer Engineering


CERTIFICATION
ABSTRACT

Website Design
and learning
HTML were the
main objective
of this
internship. To
develop a web
based
application
there are
several
programming
languages that
are in use.
Some of them
are only used
for the
frontend and
backend
design of the
software. For
example,
HTML3,
HTML4,
HTML5, CSS,
Bootstrap,
JavaScript etc.
There are also
some other
programming
languages that
are used to
develop the
dynamic
functions of
the software
or application.
For example-
PHP,
Java etc.
Nowadays
there are also
some
frameworks
that use
vastly.
Frameworks
are basically
structured
programming
by
using Model,
View and
Controller. It is
also called as
MVC. If
we develop
web based
application
that is very
useful for us
because we
can access it
from anywhere
in the world. It
is very
helpful for our
daily life. That
is why I choose
subject of my
report as “WEB
DESIGN”.
Training in
Universal
Informatics
added huge
experiences in
my upcoming
career. Solving
real
life problems
was another
key issue.
This report
takes us
through all the
details of
WEBSITE
DESIGN
knowledge and
experience
gathered
during this
internship
period.
Website Design
and learning
HTML were the
main objective
of this
internship. To
develop a web
based
application
there are
several
programming
languages that
are in use.
Some of them
are only used
for the
frontend and
backend
design of the
software. For
example,
HTML3,
HTML4,
HTML5, CSS,
Bootstrap,
JavaScript etc.
There are also
some other
programming
languages that
are used to
develop the
dynamic
functions of
the software
or application.
For example-
PHP,
Java etc.
Nowadays
there are also
some
frameworks
that use
vastly.
Frameworks
are basically
structured
programming
by
using Model,
View and
Controller. It is
also called as
MVC. If
we develop
web based
application
that is very
useful for us
because we
can access it
from anywhere
in the world. It
is very
helpful for our
daily life. That
is why I choose
subject of my
report as “WEB
DESIGN”.
Training in
Universal
Informatics
added huge
experiences in
my upcoming
career. Solving
real
life problems
was another
key issue.
This report
takes us
through all the
details of
WEBSITE
DESIGN
knowledge and
experience
gathered
during this
internship
period.
Website Design
and learning
HTML were the
main objective
of this
internship. To
develop a web
based
application
there are
several
programming
languages that
are in use.
Some of them
are only used
for the
frontend and
backend
design of the
software. For
example,
HTML3,
HTML4,
HTML5, CSS,
Bootstrap,
JavaScript etc.
There are also
some other
programming
languages that
are used to
develop the
dynamic
functions of
the software
or application.
For example-
PHP,
Java etc.
Nowadays
there are also
some
frameworks
that use
vastly.
Frameworks
are basically
structured
programming
by
using Model,
View and
Controller. It is
also called as
MVC. If
we develop
web based
application
that is very
useful for us
because we
can access it
from anywhere
in the world. It
is very
helpful for our
daily life. That
is why I choose
subject of my
report as “WEB
DESIGN”.
Training in
Universal
Informatics
added huge
experiences in
my upcoming
career. Solving
real
life problems
was another
key issue.
This report
takes us
through all the
details of
WEBSITE
DESIGN
knowledge and
experience
gathered
during this
internship
period.
Website Design
and learning
HTML were the
main objective
of this
internship. To
develop a web
based
application
there are
several
programming
languages that
are in use.
Some of them
are only used
for the
frontend and
backend
design of the
software. For
example,
HTML3,
HTML4,
HTML5, CSS,
Bootstrap,
JavaScript etc.
There are also
some other
programming
languages that
are used to
develop the
dynamic
functions of
the software
or application.
For example-
PHP,
Java etc.
Nowadays
there are also
some
frameworks
that use
vastly.
Frameworks
are basically
structured
programming
by
using Model,
View and
Controller. It is
also called as
MVC. If
we develop
web based
application
that is very
useful for us
because we
can access it
from anywhere
in the world. It
is very
helpful for our
daily life. That
is why I choose
subject of my
report as “WEB
DESIGN”.
Training in
Universal
Informatics
added huge
experiences in
my upcoming
career. Solving
real
life problems
was another
key issue.
This report
takes us
through all the
details of
WEBSITE
DESIGN
knowledge and
experience
gathered
during this
internship
period.
Website Design
and learning
HTML were the
main objective
of this
internship. To
develop a web
based
application
there are
several
programming
languages that
are in use.
Some of them
are only used
for the
frontend and
backend
design of the
software. For
example,
HTML3,
HTML4,
HTML5, CSS,
Bootstrap,
JavaScript etc.
There are also
some other
programming
languages that
are used to
develop the
dynamic
functions of
the software
or application.
For example-
PHP,
Java etc.
Nowadays
there are also
some
frameworks
that use
vastly.
Frameworks
are basically
structured
programming
by
using Model,
View and
Controller. It is
also called as
MVC. If
we develop
web based
application
that is very
useful for us
because we
can access it
from anywhere
in the world. It
is very
helpful for our
daily life. That
is why I choose
subject of my
report as “WEB
DESIGN”.
Training in
Universal
Informatics
added huge
experiences in
my upcoming
career. Solving
real
life problems
was another
key issue.
This report
takes us
through all the
details of
WEBSITE
DESIGN
knowledge and
experience
gathered
during this
internship
period.
Website Design
and learning
HTML were the
main objective
of this
internship. To
develop a web
based
application
there are
several
programming
languages that
are in use.
Some of them
are only used
for the
frontend and
backend
design of the
software. For
example,
HTML3,
HTML4,
HTML5, CSS,
Bootstrap,
JavaScript etc.
There are also
some other
programming
languages that
are used to
develop the
dynamic
functions of
the software
or application.
For example-
PHP,
Java etc.
Nowadays
there are also
some
frameworks
that use
vastly.
Frameworks
are basically
structured
programming
by
using Model,
View and
Controller. It is
also called as
MVC. If
we develop
web based
application
that is very
useful for us
because we
can access it
from anywhere
in the world. It
is very
helpful for our
daily life. That
is why I choose
subject of my
report as “WEB
DESIGN”.
Training in
Universal
Informatics
added huge
experiences in
my upcoming
career. Solving
real
life problems
was another
key issue.
This report
takes us
through all the
details of
WEBSITE
DESIGN
knowledge and
experience
gathered
during this
internship
period.
Website Design
and learning
HTML were the
main objective
of this
internship. To
develop a web
based
application
there are
several
programming
languages that
are in use.
Some of them
are only used
for the
frontend and
backend
design of the
software. For
example,
HTML3,
HTML4,
HTML5, CSS,
Bootstrap,
JavaScript etc.
There are also
some other
programming
languages that
are used to
develop the
dynamic
functions of
the software
or application.
For example-
PHP,
Java etc.
Nowadays
there are also
some
frameworks
that use
vastly.
Frameworks
are basically
structured
programming
by
using Model,
View and
Controller. It is
also called as
MVC. If
we develop
web based
application
that is very
useful for us
because we
can access it
from anywhere
in the world. It
is very
helpful for our
daily life. That
is why I choose
subject of my
report as “WEB
DESIGN”.
Training in
Universal
Informatics
added huge
experiences in
my upcoming
career. Solving
real
life problems
was another
key issue.
This report
takes us
through all the
details of
WEBSITE
DESIGN
knowledge and
experience
gathered
during this
internship
period.
Website Design
and learning
HTML were the
main objective
of this
internship. To
develop a web
based
application
there are
several
programming
languages that
are in use.
Some of them
are only used
for the
frontend and
backend
design of the
software. For
example,
HTML3,
HTML4,
HTML5, CSS,
Bootstrap,
JavaScript etc.
There are also
some other
programming
languages that
are used to
develop the
dynamic
Website Design
and learning
HTML were the
main objective
of this
internship. To
develop a web
based
application
there are
several
programming
languages that
are in use.
Some of them
are only used
for the
frontend and
backend
design of the
software. For
example,
HTML3,
HTML4,
HTML5, CSS,
Bootstrap,
JavaScript etc.
There are also
some other
programming
languages that
are used to
develop the
dynamic
Website Design
and learning
HTML were the
main objective
of this
internship. To
develop a web
based
application
there are
several
programming
languages that
are in use.
Some of them
are only used
for the
frontend and
backend
design of the
software. For
example,
HTML3,
HTML4,
HTML5, CSS,
Bootstrap,
JavaScript etc.
There are also
some other
programming
languages that
are used to
develop the
dynamic
Website Design
and learning
HTML were the
main objective
of this
internship. To
develop a web
based
application
there are
several
programming
languages that
are in use.
Some of them
are only used
for the
frontend and
backend
design of the
software. For
example,
HTML3,
HTML4,
HTML5, CSS,
Bootstrap,
JavaScript etc.
There are also
some other
programming
languages that
are used to
develop the
dynamic
Website Design
and learning
HTML were the
main objective
of this
internship. To
develop a web
based
application
there are
several
programming
languages that
are in use.
Some of them
are only used
for the
frontend and
backend
design of the
software. For
example,
HTML3,
HTML4,
HTML5, CSS,
Bootstrap,
JavaScript etc.
There are also
some other
programming
languages that
are used to
develop the
dynamic
Website Design
and learning
HTML were the
main objective
of this
internship. To
develop a web
based
application
there are
several
programming
languages that
are in use.
Some of them
are only used
for the
frontend and
backend
design of the
software. For
example,
HTML3,
HTML4,
HTML5, CSS,
Bootstrap,
JavaScript etc.
There are also
some other
programming
languages that
are used to
develop the
dynamic
Website Design
and learning
HTML were the
main objective
of this
internship. To
develop a web
based
application
there are
several
programming
languages that
are in use.
Some of them
are only used
for the
frontend and
backend
design of the
software. For
example,
HTML3,
HTML4,
HTML5, CSS,
Bootstrap,
JavaScript etc.
There are also
some other
programming
languages that
are used to
develop the
dynamic
Website Design
and learning
HTML were the
main objective
of this
internship. To
develop a web
based
application
there are
several
programming
languages that
are in use.
Some of them
are only used
for the
frontend and
backend
design of the
software. For
example,
HTML3,
HTML4,
HTML5, CSS,
Bootstrap,
JavaScript etc.
There are also
some other
programming
languages that
are used to
develop the
dynamic
Website Design
and learning
HTML were the
main objective
of this
internship. To
develop a web
based
application
there are
several
programming
languages that
are in use.
Some of them
are only used
for the
frontend and
backend
design of the
software. For
example,
HTML3,
HTML4,
HTML5, CSS,
Bootstrap,
JavaScript etc.
There are also
some other
programming
languages that
are used to
develop the
dynamic
The present course entitled “CSS and JavaScript” has been conducted at
Udemy – Online Courses. The course uses interdisciplinary techniques to
create structureof the website’s using HTML, Adds style and formatting to
these structures using CSS, and then JavaScript turns those stylized
components into something that a user can interact with.
For Example you want to build a website where users can fill out a form for
a contest. HTML will allow you to designate the difference between the
text that announces the contest and the text that asks questions within the
form such as a participant’s name, age, address, and so on. CSS will allow
you to dress all this text up, giving it formatting, color, and style while
helping you build the boxes where users will input their answers.
JavaScript will then enable you to program a little box that pops up and
says “Thanks for entering!” when everything has been filled out and
submitted. It can even insert the first name that the person submitted in the
form for a more personalized message.

CSS
1. CSS (Cascading Style Sheet)
CSS is the language we use to style an HTML document.

CSS describes how HTML elements should be displayed.

What is CSS?
 CSS stands for Cascading Style Sheets
 CSS describes how HTML elements are to be displayed on screen,
paper, or in other media
 CSS saves a lot of work. It can control the layout of multiple web
pages all at once
 External stylesheets are stored in CSS files.

Why Use CSS?


CSS is used to define styles for your web pages, including the design,
layout and variations in display for different devices and screen sizes.

CSS Solved a Big Problem


HTML was NEVER intended to contain tags for formatting a web page!

HTML was created to describe the content of a web page, like:

<h1>This is a heading</h1>

<p>This is a paragraph.</p>

When tags like <font>, and color attributes were added to the HTML 3.2
specification, it started a nightmare for web developers. Development of
large websites, where fonts and color information were added to every
single page, became a long and expensive process.

To solve this problem, the World Wide Web Consortium (W3C) created
CSS.

CSS removed the style formatting from the HTML page!

[Link] Syntax
A CSS rule consists of a selector and a declaration block.

The selector points to the HTML element you want to style.

The declaration block contains one or more declarations separated by


semicolons.
Each declaration includes a CSS property name and a value, separated
by a colon.

Multiple CSS declarations are separated with semicolons, and declaration


blocks are surrounded by curly braces.

Example:
In this example all <p> elements will be center-aligned, with a red text
color:

p {
color: black;
text-align: center;
}

[Link] Selectors
CSS selectors are used to "find" (or select) the HTML elements you want
to style.

We can divide CSS selectors into five categories:

 Simple selectors (select elements based on name, id, class)


 Combinator selectors (select elements based on a specific
relationship between them)
 Pseudo-class selectors (select elements based on a certain state)
 Pseudo-elements selectors (select and style a part of an element)
 Attribute selectors (select elements based on an attribute or
attribute value)

3.1 The CSS element Selector


The element selector selects HTML elements based on the element
name.

Example:
Here, all <p> elements on the page will be center-aligned, with a red
text color:

p {
text-align: center;
color: black;
}

3.2 The CSS id Selector


The id selector uses the id attribute of an HTML element to select a
specific element.

The id of an element is unique within a page, so the id selector is used to


select one unique element!

To select an element with a specific id, write a hash (#) character,


followed by the id of the element.

Example:
The CSS rule below will be applied to the HTML element with id="para1":

#para1 {
text-align: center;
color: red;
}

3.3 The CSS class Selector


The class selector selects HTML elements with a specific class attribute.

To select elements with a specific class, write a period (.) character,


followed by the class name.

You can also specify that only specific HTML elements should be affected
by a class.

Example:
In this example all HTML elements with class="center" will be red and
center-aligned:

.center {
text-align: center;
color: red;
}

In this example only <p> elements with class="center" will be red and
center-aligned:

[Link] {
text-align: center;
color: red;
}

3.4 The CSS Universal Selector


The universal selector (*) selects all HTML elements on the page.

Example:
The CSS rule below will affect every HTML element on the page:

* {
text-align: center;
color: blue;
}

3.5 The CSS Grouping Selector


The grouping selector selects all the HTML elements with the same style
definitions.

To group selectors, separate each selector with a comma.

Example:
In this example we have grouped the selectors from the code above:

h1, h2, p {
text-align: center;
color: red;
}

[Link] To Add CSS


Three Ways to Insert CSS
There are three ways of inserting a style sheet:

 External CSS
 Internal CSS
 Inline CSS

4.1 External CSS


With an external style sheet, you can change the look of an entire
website by changing just one file!

Each HTML page must include a reference to the external style sheet file
inside the <link> element, inside the head section.
An external style sheet can be written in any text editor, and must be
saved with a .css extension.

The external .css file should not contain any HTML tags.

4.2 Internal CSS


An internal style sheet may be used if one single HTML page has a
unique style.

The internal style is defined inside the <style> element, inside the head
section.

Example:
Internal styles are defined within the <style> element, inside the
<head> section of an HTML page:

<head>
<style>
body {
background-color: linen;
}
h1 {
color: maroon;
margin-left: 40px;
}
</style>
</head>

4.3 Inline CSS


An inline style may be used to apply a unique style for a single element.

To use inline styles, add the style attribute to the relevant element. The
style attribute can contain any CSS property.

Example:
Inline styles are defined within the "style" attribute of the relevant
element:

<body>

<h1 style="color:blue;text-align:center;">This is a
heading</h1>
<p style="color:red;">This is a paragraph.</p>

</body>
4.4 Cascading Order
What style will be used when there is more than one style specified for
an HTML element?

All the styles in a page will "cascade" into a new "virtual" style sheet by
the following rules, where number one has the highest priority:

1. Inline style (inside an HTML element)


2. External and internal style sheets (in the head section)
3. Browser default

So, an inline style has the highest priority, and will override external and
internal styles and browser defaults.

[Link] Colors
Colors are specified using predefined color names, or RGB, HEX, HSL,
RGBA, HSLA values. In CSS, a color can be specified by using a predefined
color name. CSS/HTML support 140 standard color names.

You can set the color of text, color of borders, background color for HTML
elements.

CSS Color Values


In CSS, colors can also be specified using RGB values, HEX values, HSL
values, RGBA values, and HSLA values

5.1 RGB Value


In CSS, a color can be specified as an RGB value, using this formula:

rgb(red, green, blue)

Each parameter (red, green, and blue) defines the intensity of the color
between 0 and 255.

For example, rgb(255, 0, 0) is displayed as red, because red is set to its


highest value (255) and the others are set to 0.

To display black, set all color parameters to 0, like this: rgb(0, 0, 0).

To display white, set all color parameters to 255, like this: rgb(255, 255,
255).

5.2 HEX Value


In CSS, a color can be specified using a hexadecimal value in the form:
#rrggbb
Where rr (red), gg (green) and bb (blue) are hexadecimal values between
00 and ff (same as decimal 0-255).

For example, #ff0000 is displayed as red, because red is set to its


highest value (ff) and the others are set to the lowest value (00).

To display black, set all values to 00, like this: #000000.

To display white, set all values to ff, like this: #ffffff.

5.3 HSL Value


In CSS, a color can be specified using hue, saturation, and lightness (HSL)
in the form:

hsl(hue, saturation, lightness)


Hue is a degree on the color wheel from 0 to 360. 0 is red, 120 is green,
and 240 is blue.

Saturation is a percentage value. 0% means a shade of gray, and 100%


is the full color.

Lightness is also a percentage. 0% is black, 50% is neither light or dark,


100% is white

[Link] Text
CSS has a lot of properties for formatting text.

6.1 Text Color


The color property is used to set the color of the text. The color is
specified by:

a color name - like "red"

a HEX value - like "#ff0000"

an RGB value - like "rgb(255,0,0)"

The default text color for a page is defined in the body selector.

6.2 Text Alignment and Text


Direction
The text-align property is used to set the horizontal alignment of a text.

A text can be left or right aligned, centered, or justified.

When the text-align property is set to "justify", each line is stretched so


that every line has equal width, and the left and right margins are
straight (like in magazines and newspapers).

he direction and unicode-bidi properties can be used to change the text


direction of an element.

6.3 CSS Text Decoration


 text-decoration-line
 text-decoration-color
 text-decoration-style
 text-decoration-thickness
 text-decoration

The text-decoration-line property is used to add a decoration line to


text.

The text-decoration-color property is used to set the color of the


decoration line.

The text-decoration-style property is used to set the style of the


decoration line.

The text-decoration-thickness property is used to set the thickness


of the decoration line.

Tip: All links in HTML are underlined by default. Sometimes you see
that links are styled with no underline. The text-decoration: none; is
used to remove the underline from links, like this:

Example:
a {
text-decoration: none;
}

6.4 Text Transformation


The text-transform property is used to specify uppercase and
lowercase letters in a text.

It can be used to turn everything into uppercase or lowercase letters, or


capitalize the first letter of each word:
Example:
[Link] {
text-transform: uppercase;
}

[Link] {
text-transform: lowercase;
}

[Link] {
text-transform: capitalize;
}

6.5 CSS Text Spacing


 text-indent
 letter-spacing
 line-height
 word-spacing
 white-space

The text-indent property is used to specify the indentation of the first


line of a text:

The letter-spacing property is used to specify the space between


the characters in a text.

The line-height property is used to specify the space between lines.

The word-spacing property is used to specify the space between the


words in a text.

The white-space property specifies how white-space inside an element


is handled.

[Link] Box Model


In CSS, the term "box model" is used when talking about design and
layout.

The CSS box model is essentially a box that wraps around every HTML
element. It consists of: content, padding, borders and margins. The
image below illustrates the box model:
Explanation of the different parts:

 Content - The content of the box, where text and images appear
 Padding - Clears an area around the content. The padding is
transparent
 Border - A border that goes around the padding and content
 Margin - Clears an area outside the border. The margin is
transparent

Width and Height of an Element


In order to set the width and height of an element correctly in all
browsers, you need to know how the box model works.

Important: When you set the width and height properties of an element
with CSS, you just set the width and height of the content area. To
calculate the total width and height of an element, you must also include
the padding and borders.

Example:
This <div> element will have a total width of 350px and a total height of
80px:

div {
width: 320px;
height: 50px;
padding: 10px;
border: 5px solid gray;
margin: 0;
}

Here is the calculation:


320px (width of content area)
+ 20px (left padding + right padding)
+ 10px (left border + right border)
= 350px (total width)

50px (height of content area)


+ 20px (top padding + bottom padding)
+ 10px (top border + bottom border)
= 80px (total height)

The total width of an element should be calculated like this:

Total element width = width + left padding + right padding + left border
+ right border

The total height of an element should be calculated like this:

Total element height = height + top padding + bottom padding + top


border + bottom border

Note: The margin property also affects the total space that the box will
take up on the page, but the margin is not included in the actual size of
the box. The box's total width and height stops at the border

[Link] Comments
CSS comments are not displayed in the browser, but they can help
document your source code.

Comments are used to explain the code, and may help when you edit the
source code at a later date.

Comments are ignored by browsers.

A CSS comment is placed inside the <style> element, and starts


with /* and ends with */:

Example:
/* This is a single-line comment */
p {
color: red;
}

You can add comments wherever you want in the code.

[Link] Links
With CSS, links can be styled in many different ways.

Styling Links
Links can be styled with any CSS property (e.g. color, font-
family, background, etc.).

In addition, links can be styled differently depending on what state they


are in.

The four links states are:

 a:link - a normal, unvisited link


 a:visited - a link the user has visited
 a:hover - a link when the user mouses over it
 a:active - a link the moment it is clicked

The text-decoration property is mostly used to remove underlines from


links.

The background-color property can be used to specify a background


color for links.

When setting the style for several link states, there are some order rules:

 a:hover MUST come after a:link and a:visited


 a:active MUST come after a:hover

This example demonstrates a more advanced example where we


combine several CSS properties to display links as boxes/buttons:

Example:
a:link, a:visited {
background-color: #f44336;
color: white;
padding: 14px 25px;
text-align: center;
text-decoration: none;
display: inline-block;
}

a:hover, a:active {
background-color: red;
}

[Link] Units
CSS has several different units for expressing a length.
Many CSS properties take "length" values, such
as width, margin, padding, font-size, etc.

Length is a number followed by a length unit, such as 10px, 2em, etc.

Note: A whitespace cannot appear between the number and the unit.
However, if the value is 0, the unit can be omitted.

For some CSS properties, negative lengths are allowed.

There are two types of length units: absolute and relative.

Absolute Lengths
The absolute length units are fixed and a length expressed in any of
these will appear as exactly that size.

Absolute length units are not recommended for use on screen, because
screen sizes vary so much. However, they can be used if the output
medium is known, such as for print layout.

* Pixels (px) are relative to the viewing device. For low-dpi devices, 1px is
one device pixel (dot) of the display. For printers and high resolution
screens 1px implies multiple device pixels.

Table on the next page

Relative Lengths
Relative length units specify a length relative to another length property.
Relative length units scale better between different rendering mediums .
Browser Support
The numbers in the table specify the first browser version that fully
supports the length unit.
-----------------------------------------------
----------------------------

JavaScript
[Link] Introduction
JavaScript is the world's most popular programming language.

JavaScript is the programming language of the Web.

JavaScript is easy to learn.

Why Study JavaScript?


JavaScript is one of the 3 languages all web developers must learn:

1. HTML to define the content of web pages

2. CSS to specify the layout of web pages

3. JavaScript to program the behavior of web pages

JavaScript Can Change HTML Content


One of many JavaScript HTML methods is getElementById().
The example below "finds" an HTML element (with id="demo"), and
changes the element content (innerHTML) to "Hello JavaScript":

Example:
[Link]("demo").innerHTML = "HelloJavaSc
ript";

JavaScript Can Change HTML


Attribute Values
JS allows you to access, modify, and add elements dynamically, change
styles and classes, handle events, and perform other operations on the
document.

In this example JavaScript changes the value of the src (source)


attribute of an <img> tag

Example on the next Page:

JavaScript Can Change HTML Styles


(CSS)
Changing the style of an HTML element, is a variant of changing an HTML
attribute:

Example:
[Link]("demo").[Link] = "35px";

JavaScript Can Hide HTML Elements


Hiding HTML elements can be done by changing the display style:
Example:
[Link]("demo").[Link] = "none";

JavaScript Can Show HTML Elements


Showing hidden HTML elements can also be done by changing
the display style:

Example:
[Link]("demo").[Link] = "block";

JavaScript and Java are completely different languages, both in concept


and design.

JavaScript was invented by Brendan Eich in 1995, and became an ECMA


standard in 1997.

ECMA-262 is the official name of the standard. ECMAScript is the official


name of the language.

[Link] Where To
The <script> Tag
In HTML, JavaScript code is insert between <script> and </script> tags.

Example:
<script>
[Link]("demo").innerHTML = "My First
JavaScript";
</script>

Old JavaScript examples may use a type attribute: <script


type="text/javascript">.

The type attribute is not required. JavaScript is the default scripting


language in HTML.

JavaScript Functions and Events


A JavaScript function is a block of JavaScript code, that can be
executed when "called" for.
For example, a function can be called when an event occurs, like when
the user clicks a button.

JavaScript in <head> or <body>


You can place any number of scripts in an HTML [Link] can be
placed in the <body>, or in the <head> section of an HTML page, or in
both.

In this example, a JavaScript function is placed in the <head> section


of an HTML page.

The function is invoked (called) when a button is clicked:

<head>
<script>
function myFunction() {
[Link]("demo").innerHTML = "Paragraph
changed.";
}
</script>
</head>

In this example, a JavaScript function is placed in the <body> section


of an HTML page.

The function is invoked (called) when a button is clicked:

<html>
<body>

<h2>Demo JavaScript in Body</h2>

<p id="demo">A Paragraph</p>

<button type="button" onclick="myFunction()">Try


it</button>

<script>
function myFunction() {
[Link]("demo").innerHTML = "Paragraph
changed.";
}
</script>

</body>
</html>

External JavaScript
Scripts can also be placed in external files:

External file: [Link]


function myFunction() {
[Link]("demo").innerHTML = "Paragraph
changed.";
}

External scripts are practical when the same code is used in many
different web pages.

JavaScript files have the file extension .js.

To use an external script, put the name of the script file in


the src (source) attribute of a <script> tag:

Example:
<script src="[Link]"></script>

[Link] Output
JavaScript Display Possibilities
JavaScript can "display" data in different ways:

 Writing into an HTML element, using innerHTML.


 Writing into the HTML output using [Link]().
 Writing into an alert box, using [Link]().
 Writing into the browser console, using [Link]().

3.1 Using innerHTML


To access an HTML element, JavaScript can use
the [Link](id) method.

The id attribute defines the HTML element. The innerHTML property


defines the HTML content:

Example:
<html>
<body>

<h1>My First Web Page</h1>


<p>My First Paragraph</p>

<p id="demo"></p>

<script>
[Link]("demo").innerHTML = 5 + 6;
</script>

</body>
</html>

Changing the innerHTML property of an HTML element is a common way


to display data in HTML.

3.2 Using [Link]( )


For testing purposes, it is convenient to use [Link]():

Using [Link]() after an HTML document is loaded, will delete all


existing HTML

Example:
<!DOCTYPE html>
<html>
<body>

<h1>My First Web Page</h1>


<p>My first paragraph.</p>

<script>
[Link](5 + 6);
</script>

</body>
</html>

The [Link]() method should only be used for testing.

3.3Using [Link]( )
You can use an alert box to display data.

You can skip the window keyword.

In JavaScript, the window object is the global scope object. This means
that variables, properties, and methods by default belong to the window
object. This also means that specifying the window keyword is optional:
Example:
<!DOCTYPE html>
<html>
<body>

<h1>My First Web Page</h1>


<p>My first paragraph.</p>

<script>
alert(5 + 6);
</script>

</body>
</html>

One useful function that's native to JavaScript is the alert() function. This
function will display text in a dialog box that pops up on the screen.

3.4 Using [Link]( )


For debugging purposes, you can call the [Link]() method in the
browser to display data.

Example:
<!DOCTYPE html>
<html>
<body>

<script>
[Link](5 + 6);
</script>

</body>
</html>

JavaScript Print
JavaScript does not have any print object or print methods.

You cannot access output devices from JavaScript.

The only exception is that you can call the [Link]() method in
the browser to print the content of the current window.
Example:
<!DOCTYPE html>
<html>
<body>

<button onclick="[Link]()">Print this page</button>

</body>
</html>

[Link] Statements
Example:
let x, y, z; // Statement 1
x = 5; // Statement 2
y = 6; // Statement 3
z = x + y; // Statement 4

JavaScript Programs
A computer program is a list of "instructions" to be "executed" by a
computer.

In a programming language, these programming instructions are


called statements.

A JavaScript program is a list of programming statements.

In HTML, JavaScript programs are executed by the web browser.

JavaScript Statements
JavaScript statements are composed of:

Values, Operators, Expressions, Keywords, and Comments.

This statement tells the browser to write "Hello Dolly." inside an HTML
element with id="demo":

Example:
[Link]("demo").innerHTML = "Hello Dolly.";

Most JavaScript programs contain many JavaScript statements.


The statements are executed, one by one, in the same order as they are
written.

Semicolons ;
Semicolons separate JavaScript statements.

Add a semicolon at the end of each executable statement:

Examples:
let a, b, c; // Declare 3 variables
a = 5; // Assign the value 5 to a
b = 6; // Assign the value 6 to b
c = a + b; // Assign the sum of a and b to c

JavaScript White Space


JavaScript ignores multiple spaces. You can add white space to your
script to make it more readable.

JavaScript Keywords
JavaScript statements often start with a keyword to identify the
JavaScript action to be performed.

Here is a list of some of the keywords you will learn about in this tutorial:

[Link] Syntax
JavaScript syntax is the set of rules, how JavaScript programs are
constructed:

// How to create variables:


var x;
let y;

// How to use variables:


x = 5;
y = 6;
let z = x + y;

JavaScript Values
The JavaScript syntax defines two types of values:

Fixed values

Variable values

Fixed values are called Literals.

Variable values are called Variables

JavaScript Literals
The two most important syntax rules for fixed values are:

1. Numbers are written with or without decimals.

2. Strings are text, written within double or single quotes.

JavaScript Variables
In a programming language, variables are used to store data values.

JavaScript uses the keywords var, let and const to declare variables.

An equal sign is used to assign values to variables.

JavaScript Operators
JavaScript uses arithmetic operators ( + - * / ) to compute values:

JavaScript uses an assignment operator ( = ) to assign values to


variables:

JavaScript Expressions
An expression is a combination of values, variables, and operators,
which computes to a value.

The computation is called an evaluation.

Expressions can also contain variable values

The values can be of various types, such as numbers and strings.

JavaScript Keywords
JavaScript keywords are used to identify actions to be performed.

The let keyword tells the browser to create variables

The var keyword also tells the browser to create variables.

JavaScript Comments
Not all JavaScript statements are "executed".

Code after double slashes // or between /* and */ is treated as


a comment.

Comments are ignored, and will not be executed:

let x = 5; // I will be executed

// x = 6; I will NOT be executed

JavaScript Identifiers / Names


Identifiers are JavaScript names.

Identifiers are used to name variables and keywords, and functions.

The rules for legal names are the same in most programming languages.

A JavaScript name must begin with:

 A letter (A-Z or a-z)


 A dollar sign ($)
 Or an underscore (_)

Subsequent characters may be letters, digits, underscores, or dollar


signs.

JavaScript is Case Sensitive


All JavaScript identifiers are case sensitive.

The variables lastName and lastname, are two different variables:

let lastname, lastName;


lastName = "Doe";
lastname = "Peterson";

JavaScript does not interpret LET or Let as the keyword let.

Hyphens are not allowed in JavaScript. They are reserved for


subtractions.

JavaScript uses the Unicode character set.

Unicode covers (almost) all the characters, punctuations, and symbols in


the world.

[Link] Functions
A JavaScript function is a block of code designed to perform a particular
task.

A JavaScript function is executed when "something" invokes it (calls it).

Example:
// Function to compute the product of p1 and p2
function myFunction(p1, p2) {
return p1 * p2;
}

JavaScript Function Syntax


A JavaScript function is defined with the function keyword, followed by
a name, followed by parentheses ().

Function names can contain letters, digits, underscores, and dollar signs
(same rules as variables).

The parentheses may include parameter names separated by commas:


(parameter1, parameter2, ...)

The code to be executed, by the function, is placed inside curly


brackets: {}

function name(parameter1, parameter2, parameter3) {


// code to be executed
}
Function parameters are listed inside the parentheses () in the
function definition.

Function arguments are the values received by the function when it is


invoked.

Inside the function, the arguments (the parameters) behave as local


variables.

A function in JavaScript is similar to a procedure—a set of statements


that performs a task or calculates a value, but for a procedure to qualify
as a function, it should take some input and return an output where there
is some obvious relationship between the input and the output.

Function Invocation
The code inside the function will execute when

"something" invokes (calls) the function:

 When an event occurs (when a user clicks a button)


 When it is invoked (called) from JavaScript code
 Automatically (self invoked)

You will learn a lot more about function invocation later in this tutorial.

Example:
Calculate the product of two numbers, and return the result:

// Function is called, the return value will end up in x


let x = myFunction(4, 3);

function myFunction(a, b) {
// Function returns the product of a and b
return a * b;
}

Why Functions?
With functions you can reuse code

You can write code that can be used many times.

You can use the same code with different arguments, to produce
different results.

The ( ) Operator
The () operator invokes (calls) the function:

Example:
Convert Fahrenheit to Celsius:

function toCelsius(fahrenheit) {
return (5/9) * (fahrenheit-32);
}

let value = toCelsius(77);

Local Variables
Variables declared within a JavaScript function, become LOCAL to the
function.

Local variables can only be accessed from within the function.

Example:
// code here can NOT use carName

function myFunction() {
let carName = "Volvo";
// code here CAN use carName
}

// code here can NOT use carName

Since local variables are only recognized inside their functions, variables
with the same name can be used in different functions.

Local variables are created when a function starts, and deleted when the
function is completed.
-----------------------------------------------
---------------------------------

You might also like