Web-Technology (HTML, CSS, JS)
Web-Technology (HTML, CSS, JS)
Clients
A client is whatever you’re using to interact with the internet. It’s the web browser you’re
using to read this page. The web browser on your computer is one client, the web
browser on your phone is another client. There are other types of clients (like watching
Netflix or listening to Spotify), but we’ll focus on web browsers for now.
One important property of a client is that they run locally on your computer (or phone,
or game console). When we talk about “client-side”, or something that happens “in the
client”, we mean it happens on your computer. This distinction will become important
when we start talking about servers.
Servers
Static content that doesn’t change much. The tutorials at HappyCoding.io are an
example of this type of content. When you view them, you see the same thing as
everybody else, and they don’t change much over time. Other types of files like
images are often static as well.
Dynamic content that changes over time, or based on who’s viewing the page.
For example, the content of stackoverflow.com changes every time somebody
posts a question. Your Twitter feed is unique to you, based on who you follow
and what they’ve posted.
Now we know that a client is a web browser that renders HTML and runs JavaScript
locally. Where does that HTML and JavaScript come from?
The World Wide Web is about communication between web clients and web servers.
Clients are often browsers (Chrome, Edge, Safari), but they can be any type of
program or device.
What is HTTP?
Communication between client computers and web servers is done by sending HTTP
Requests and receiving HTTP Responses
File transfer protocol (FTP) is a set of rules that computers follow for the
transferring of files from one system to another over the internet. It may be used
by a business to transfer files from one computer system to another, or websites
may use FTP to upload or download files from a website's server
Using FTP allows you to transfer multiple directories at one time. If you regularly
transfer files, you know how advantageous this feature can be. Instead of
sending single files or even single directories at a time, you can send numerous
directories all at once
The World Wide Web is a system for displaying text, graphics, and audio retrieved
over... A hypertext document with its corresponding text and hyperlinks is written in
HyperText Markup Language (HTML) and is assigned an online address called a
Uniform Resource Locator (URL)
World Wide Web, which is also known as a Web, is a collection of websites or web
pages stored in web servers and connected to local computers through the internet.
These websites contain text pages, digital images, audios, videos, etc. Users can
access the content of these sites from any part of the world over the internet using their
devices such as computers, laptops, cell phones, etc. The WWW, along with internet,
enables the retrieval and display of text and media to your device.
The Web works as per the internet's basic client-server format as shown in the following
image. The servers store and transfer web pages or information to user's computers on
the network when requested by the users. A web server is a software program which
serves the web pages requested by web users using a browser. The computer of a user
who requests documents from a server is known as a client. Browser, which is installed
on the user' computer, allows users to view the retrieved documents.
Some people use the terms 'internet' and 'World Wide Web' interchangeably. They think
they are the same thing, but it is not so. Internet is entirely different from WWW. It is a
worldwide network of devices like computers, laptops, tablets, etc. It enables users to
send emails to other users and chat with them online. For example, when you send an
email or chatting with someone online, you are using the internet.
But, when you have opened a website like google.com for information, you are using
the World Wide Web; a network of servers over the internet. You request a webpage
from your computer using a browser, and the server renders that page to your browser.
Your computer is called a client who runs a program (web browser), and asks the other
computer (server) for the information it needs.
An effective website design should fulfil its intended function by conveying its particular
message whilst simultaneously engaging the visitor. Several factors such as
consistency, colours, typography, imagery, simplicity and functionality all contribute to
good website design.
When designing a website there are many key factors that will contribute to how it is
perceived. A well designed website can help build trust and guide visitors to take action.
Creating a great user experience involves making sure your website design is optimised
for usability (form and aesthetics) and how it easy is it to use (functionality).
Below are some guidelines that will help you when considering your next web project.
1. WEBSITE PURPOSE
What is the purpose of your website? Are you imparting practical information like a ‘How
to guide’? Is it an entertainment website like sports coverage or are you selling a
product to the user? There are many different purposes that websites may have but
there are core purposes common to all websites;
1. Describing Expertise
2. Building Your Reputation
3. Generating Leads
4. Sales and After Care
2. SIMPLICITY
Simplicity is the best way to go when considering the user experience and the usability
of your website. Below are ways to achieve simplicity through design.
3. NAVIGATION
Navigation is the way finding system used on websites where visitors interact and find
what they are looking for. Website navigation is key to retaining visitors
5. VISUAL HIERARCHY
Visual hierarchy is the arrangement of elements is order of importance. This is done
either by size, colour, imagery, contrast, typographically, whitespace, texture and style.
6. CONTENT
An effective web design has both great design and great content
8 LOAD TIME
Waiting for a website to load will lose visitors. Nearly half of web visitors expect a site to
load in 2 seconds or less and they will potentially leave a site that isn’t loaded within 3
seconds.
9. MOBILE FRIENDLY
More people are using their phones or other devices to browse the web. It is important
to consider building your website with a responsive layout where your website can
adjust to different screens.
Brower :-
Mobile browsers
Amazon Silk.
Apple Safari.
Brave.
Dolphin browser.
Google Chrome.
Microsoft Edge.
Mozilla Firefox.
Opera Mobile.
Cache memory is a chip-based computer component that makes retrieving data from
the computer's memory more efficient. It acts as a temporary storage area that the
computer's processor can retrieve data from easily. This temporary storage area, known
as a cache, is more readily available to the processor than the computer's main memory
source, typically some form of DRAM.
Cache memory is sometimes called CPU (central processing unit) memory because it is
typically integrated directly into the CPU chip or placed on a separate chip that has a
separate bus interconnect with the CPU. Therefore, it is more accessible to the
processor, and able to increase efficiency, because it's physically close to the
processor.
One use of the term display resolution applies to fixed-pixel-array displays such
as plasma display panels (PDP), liquid-crystal displays (LCD), Digital Light
Processing (DLP) projectors, OLED displays, and similar technologies, and is simply the
physical number of columns and rows of pixels creating the display (e.g. 1920 × 1080)
Page layout :- Page layout refers to the arrangement of text, images, and other
objects on a page. The term was initially used in desktop publishing (DTP), but is now
commonly used to describe the layout of WebPages as well. ... The page layout of a
printed or electronic document encompasses all elements of the page
What is a sitemap?
A sitemap is a file where you provide information about the pages, videos, and other
files on your site, and the relationships between them. Search engines like Google read
this file to more intelligently crawl your site. A sitemap tells Google which pages and
files you think are important in your site, and also provides valuable information about
these files: for example, for pages, when the page was last updated, how often the page
is changed, and any alternate language versions of a page.
You can use a sitemap to provide information about specific types of content on your
pages, including video and image content. For example:
A sitemap video entry can specify the video running time, category, and age-
appropriateness rating.
A sitemap image entry can include the image subject matter, type, and license.
Your site is really large. As a result, it's more likely Google web crawlers might overlook
crawling some of your new or recently updated pages.
Your site has a large archive of content pages that are isolated or not well linked to
each other. If your site pages do not naturally reference each other, you can list them in a
sitemap to ensure that Google does not overlook some of your pages.
Your site is new and has few external links to it. Googlebot and other web crawlers
crawl the web by following links from one page to another. As a result, Google might not
discover your pages if no other sites link to them.
Your site has a lot of rich media content (video, images) or is shown in Google
News. If provided, Google can take additional information from sitemaps into account for
search, where appropriate.
Your site is "small". By small, we mean about 500 pages or less on your site. (Only pages
that you think need to be in search results count toward this total.)
You're on a simple site hosting service like Blogger or Wix. If your site is on a service
that helps you set up a site quickly with pre-formatted pages and navigation elements, your
service might create a sitemap for your site automatically, and you don't need to do
anything. Search your service's documentation for the word "sitemap" to see if a sitemap is
generated automatically, or if they recommend creating your own (and if so, how to submit
a sitemap on your hosting service).
Your site is comprehensively linked internally. This means that Google can find all the
important pages on your site by following links starting from the homepage.
You don't have many media files (video, image) or news pages that you need to appear
in the index. Sitemaps can help Google find and understand video and image files, or news
articles, on your site, if you want them to appear in Google Search results. If you don't need
these results to appear in Image, Video, or News results, you might not need a sitemap.
Search engines use your website navigation to discover and index new pages. Links
help search engines to understand the content and context of the destination page, as
well as the relationships between pages.
In web development, it takes time to briefly explain business needs and features
regarding the look and feel of a website to allows that everybody is on the same page
earlier web development work starts.
The “look and feel” of a website or portion of software designates its entrance and
functionality. People may use this period to discuss how website appearances and how
it feels to steer it. The term can be used for any boundary, but it is often used in telling
websites.
In its most common terms, the “look and feel” of a website is in what way the site looks
to the user and just how it feels once he or she is cooperating through it.
– Color themes
– Images
– Design
– Complete designing
Your website’s overall look and feel is significant because it rapidly conveys an attitude
to your customers before they even start an interpretation of the content on the site.
Before you start a website rewrite, check your areas against business standards by
looking at your participants’ websites. A capability website should look new, powerful
and well planned. A website for a group of a fashion designer can be more creative with
colors, surface and pictures choices.
Look and feel can be defined using adjectives just like you would define a friend or
business assistant. By using exact adjectives, you can support the team at your
selected web development company in their layout and plan choices before they
existing their work to you.
The modest way to start a plan is to draft out an idea before you exposed any tool such
as Photoshop or Canva. Set sketch to paper or create a wireframe in software such
as OmniGraffle or Balsamic. A blueprint is where you work out all the facts about
functionality or outline before you start the project in Photoshop or other design
software. With a plan for a house, you would control where the holes and doors will go
and work from it. A wireframe is the same object for a website. Determine wherever
each piece of content will go on to each website page before starting your website
design.
Balance is all around ensuring that your plan does not tip to one side or the other. It is
similar to the balance of bulk in achieving symmetry or asymmetry.
The impression of grids is strictly related to that of stability. Grids are a sequence of
horizontal and vertical leaders that help you “classify” a design. Think of columns.
Columns expand readability, creating a leaf’s content calmer to engage. Space and the
custom of the Rule of Thirds make all easier on the eye.
Color is the primary place we use this material. Color can help carry a mood or a
sensation. The designer wants to be mindful of national differences as well when
making global websites because colors that mean one gadget in the United States can
mean something entirely different in another nation.
Create Graphics
great design doesn’t require decorative graphics. But poor graphics will certainly hurt a
plan. Graphics add to the pictorial message. Websites like Web Designer Wall have
imposing illustrations, while others are understated.
What is HTML?
</body>
</html>
Web Browsers
The purpose of a web browser (Chrome, Edge, Firefox, Safari) is to read HTML
documents and display them correctly.
A browser does not display the HTML tags, but uses them to determine how to display
the document:
HTML Documents
All HTML documents must start with a document type declaration: <!DOCTYPE html>.
The HTML document itself begins with <html> and ends with </html>.
The visible part of the HTML document is between <body> and </body>.
Example
<!DOCTYPE html>
<html>
<body>
</body>
</html>
Try it Yourself »
TAGS:-
2) Single tag:-
• <br>
• <hr>
• <li>
The <!DOCTYPE> declaration represents the document type, and helps browsers to
display web pages correctly.
It must only appear once, at the top of the page (before any HTML tags).
<!DOCTYPE html>
HTML Headings
<h1> defines the most important heading. <h6> defines the least important heading:
Example
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
HTML Headings
<h1> defines the most important heading. <h6> defines the least important heading.
<!DOCTYPE html>
<html>
<body>
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
</body>
</html>
HTML Paragraphs
A paragraph always starts on a new line, and browsers automatically add some white
space (a margin) before and after a paragraph.
<!DOCTYPE html>
<html>
<body>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
</body>
</html>
The <hr> tag defines a thematic break in an HTML page, and is most often displayed as
a horizontal rule.
The <hr> element is used to separate content (or define a change) in an HTML page:
<!DOCTYPE html>
<html>
<body>
<hr>
<hr>
</body>
</html>
Use <br> if you want a line break (a new line) without starting a new paragraph
The text inside a <pre> element is displayed in a fixed-width font (usually Courier), and
it preserves both spaces and line breaks:
<!DOCTYPE html>
<html>
<body>
<pre>
</pre>
</body>
</html>
Physical Tags :
Definition : Physical tags are used to indicate exactly how specific characters are
to be formatted.
Logical Tags :
Definition : Logical tags are used to indicate to the visually impaired that there is
some emphasizes on the text. Each browser has its own technique as to how to
indicate to its viewer that the text between the tags are different.
<html>
<head>
</head>
<body bgcolor="yellow">
<h1>Web -Technology</h1>
<hr>
</font>
</font> </body></html>
i am not wel<br>
<ol type="i">
<li>apple
<li> banana
<li>graps
</ol>
<ul >
<li type="disc">patato
<li type="circle">palak
</ul>
<hr>
Table tag:-
• The HTML <table> eletent represents tabular data — that is, information
presented in a two-dimensional table comprised of rows and columns of cells
containing data.
• An HTML table consists of the <table> element and one or more <tr>, <th>,
and <td> elements.
Caption tag:-
The <caption> tag must be inserted immediately after the <table> tag.
SYNTAX:- <CAPTION>……………</CAPTION>
ATTRIBUTES IN Caption
<html>
<head>
<title>table</title>
</head>
<body bgcolor="yellow">
</font >
<center>
<tr>
<td>rollno
<td>name</td>
<td>marks</td>
</tr>
<tr>
<td> 101</td>
<td>yogesh</td>
<td>420</td>
</tr>
</font>
</center>
</table>
</body></html>
Colspan
<html>
<head>
<title>table</title>
</head>
<body bgcolor="yellow">
<center>
<tr>
<th>rollno</th>
</tr>
<tr>
<td> </td>
</tr>
</font>
</center>
</table>
</body>
</html>
* Web page can contain links that directly goes to other pages
* The LINKS starts at the ((Source)) anchor and points to the ((Destination)) anchor.
These LINKIS are called as hyperlinks.
<html>
<head>
</head>
<body bgcolor="yellow">
<br><hr>
//here <a> </a> is the anchor tag, it is used to link the page and doucment .....//
</body>
</html>
HYPER LINKS
*Thus , we can create hyper links using text or images available on our any web pages.
* A HYPER LINK (OR LINK) is a word, group of words, or image that we can click on to
jump to a new document or new section within the current document.
HYPER LINKS
• By default, the linked page will be displayed in the current browser window. To
change this, you must specify another target for the link.
• _self - Default. Opens the document in the same window/tab as it was clicked
•
PROF. YOGESH DESHMUKH www.dacc.edu.in
DNYANSAGAR ARTS AND COMMERCE COLLEGE, BALEWADI,PUNE – 45
• Example
* When we move the cursor over a link in a web page, the arrow will turn in to a little
hand.
Syntax :
syntax explanation :
href : is the attribute use to specify the destination address of the link used.
<!DOCTYPE html>
<html>
<body>
<p>If target="_blank", the link will open in a new browser window or tab.</p>
</body>
</html>
HTML Form
The <input> element can be displayed in several ways, depending on the type attribute
3. checkbox :- accept only true or false we can select more then one option out of
given option
5. textarea:- it is used to give the show the input box with multiple rows and column.
6. password :- it is used with text , when we use to hide the text matter …
7. submit (button ):- it is used to submit the button ( accept the data) to upload.
8. Reset (button) :- it is used to reset the button ( cancel the data) to upload
example of forms
<html>
<head>
<title>form</title>
</head>
<body bgcolor="yellow">
<center>
<b><i>
</b></i>
</center>
<left>
<form>
<h2>
<option value="5">bhopal
</select><br>
</form>
</left></body>
</html>
When you move the mouse over a link, the mouse arrow will turn into a little hand.
<!DOCTYPE html>
<html>
<body>
<h1>HTML Links</h1>
</body>
</html>
Both examples above are using an absolute URL (a full web address) in
the href attribute.
A local link (a link to a page within the same website) is specified with a relative
URL (without the "https://www" part):
<!DOCTYPE html>
<html>
<body>
<h2>Absolute URLs</h2>
<p><a href="https://www.w3.org/">W3C</a></p>
<p><a href="https://www.google.com/">Google</a></p>
<h2>Relative URLs</h2>
</body>
</html>
To use an image as a link, just put the <img> tag inside the <a> tag:
<!DOCTYPE html>
<html>
<body>
<h2>Image as a Link</h2>
</body>
</html>
The HTML <blockquote> element defines a section that is quoted from another source.
<!DOCTYPE html>
<html>
<body>
<blockquote cite="http://www.worldwildlife.org/who/index.html">
For nearly 60 years, WWF has been protecting the future of nature. The world's leading
conservation organization, WWF works in 100 countries and is supported by more than
one million members in the United States and close to five million globally.
</blockquote>
</body>
</html>
The HTML <cite> tag defines the title of a creative work (e.g. a book, a poem, a song, a
movie, a painting, a sculpture, etc.).
You can add comments to your HTML source by using the following syntax:
HTML Colors
Background Color
<!DOCTYPE html>
<html>
<body>
<p style="background-color:Tomato;">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh
euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis
nisl ut aliquip ex ea commodo consequat.
</p>
</body>
</html>
Each parameter (red, green, and blue) defines the intensity of the color with a value
between 0 and 255.
This means that there are 256 x 256 x 256 = 16777216 possible colors!
For example, rgb(255, 0, 0) is displayed as red, because red is set to its highest value
(255), and the other two (green and blue) are set to 0.
<!DOCTYPE html>
<html>
<body>
</body>
</html>
=================================================================
<!DOCTYPE html>
<html>
<body>
</body>
</html>
Block-level Elements
A block-level element always takes up the full width available (stretches out to the left
and right as far as it can).
A block level element has a top and a bottom margin, whereas an inline element does
not.
<!DOCTYPE html>
<html>
<body>
<p>The DIV element is a block element, and will always start on a new line and take up
the full width available (stretches out to the left and right as far as it can).</p>
</body>
</html>
Inline Elements
<!DOCTYPE html>
<html>
<body>
<p>The SPAN element is an inline element, and will not start on a new line and only
takes up as much width as necessary.</p>
</body>
</html>
The <div> element is often used as a container for other HTML elements.
The <div> element has no required attributes, but style, class and id are common.
When used together with CSS, the <div> element can be used to style blocks of
content:
The HTML class attribute is used to specify a class for an HTML element.
The class attribute is often used to point to a class name in a style sheet. It can also be
used by a JavaScript to access and manipulate elements with the specific class name.
In the following example we have three <div> elements with a class attribute with the
value of "city". All of the three <div> elements will be styled equally according to
the .city style definition in the head section:
<!DOCTYPE html>
<html>
<head>
<style>
.city {
background-color: tomato;
color: white;
margin: 20px;
padding: 20px;
</style>
</head>
<body>
<div class="city">
<h2>London</h2>
</div>
<div class="city">
<h2>Paris</h2>
</div>
<div class="city">
<h2>Tokyo</h2>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
.note {
font-size: 120%;
color: red;
</style>
</head>
<body>
</body>
</html>
HTML Forms
The <form> Element
The HTML <form> element is used to create an HTML form for user input:
The <form> element is a container for different types of input elements, such as: text
fields, checkboxes, radio buttons, submit buttons, etc.
An <input> element can be displayed in many ways, depending on the type attribute.
Text Fields
The <input type="text"> defines a single-line input field for text input.
<!DOCTYPE html>
<html>
<body>
<form>
</form>
<p>Also note that the default width of text input fields is 20 characters.</p>
</body>
</html>
==========================================================
The <label> element is useful for screen-reader users, because the screen-reader will
read out loud the label when the user focus on the input element.
The <label> element also help users who have difficulty clicking on very small regions
(such as radio buttons or checkboxes) - because when the user clicks the text within
the <label> element, it toggles the radio button/checkbox.
The for attribute of the <label> tag should be equal to the id attribute of
the <input> element to bind them together.
=================================================================
Radio Buttons
<!DOCTYPE html>
<html>
<body>
<h2>Radio Buttons</h2>
<form>
<label for="male">Male</label><br>
<label for="female">Female</label><br>
<label for="other">Other</label>
</form>
</body>
</html>
=============================================================
Checkboxes
Checkboxes let a user select ZERO or MORE options of a limited number of choices.
<!DOCTYPE html>
<html>
<body>
<h2>Checkboxes</h2>
<form action="/action_page.php">
</form>
</body>
</html>
The <input type="submit"> defines a button for submitting the form data to a form-
handler.
The form-handler is typically a file on the server with a script for processing input data.
<!DOCTYPE html>
<html>
<body>
<h2>HTML Forms</h2>
<form action="/action_page.php">
</form>
<p>If you click the "Submit" button, the form-data will be sent to a page called
"/action_page.php".</p>
</body>
</html>
Notice that each input field must have a name attribute to be submitted.
If the name attribute is omitted, the value of the input field will not be sent at all.
<!DOCTYPE html>
<html>
<body>
<form action="/action_page.php">
</form>
<p>If you click the "Submit" button, the form-data will be sent to a page called
"/action_page.php".</p>
<p>Notice that the value of the "First name" field will not be submitted, because the
input element does not have a name attribute.</p>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<form action="/action_page.php">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>
<input type="submit">
</form>
</body>
</html>
=================================================================
CSS saves a lot of work. It can control the layout of multiple web pages all at once.
The most common way to add CSS, is to keep the styles in separate CSS files.
However, here we will use inline and internal styling, because this is easier to
demonstrate, and easier for you to try it yourself.
Tip: You can learn much more about CSS in our CSS Tutorial.
types
1) Inline CSS
<!DOCTYPE html>
<html>
<body>
</body>
</html>
output
=============================================================
2) Internal CSS
<!DOCTYPE html>
<html>
<head>
<style>
body {background-color: powderblue;}
h1 {color: blue;}
p {color: red;}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
This is a heading
====================================================
PROF. YOGESH DESHMUKH www.dacc.edu.in
DNYANSAGAR ARTS AND COMMERCE COLLEGE, BALEWADI,PUNE – 45
3) External CSS
An external style sheet is used to define the style for many HTML pages.
With an external style sheet, you can change the look of an entire web site, by
changing one file!
To use an external style sheet, add a link to it in the <head> section of the HTML page:
=================================================================
2) this is another file it is save by bca1.html file
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="samir1.css">
</head><body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
<h2> yogesh deshmukh</h2>
</body>
</html>
out put isTry it Yourself »
This is a heading
This is a paragraph.
yogesh deshmukh
PROF. YOGESH DESHMUKH www.dacc.edu.in
DNYANSAGAR ARTS AND COMMERCE COLLEGE, BALEWADI,PUNE – 45
==============================================================
An external style sheet can be written in any text editor. The file must not contain any
HTML code, and must be saved with a .css extension.
================================================================
CSS Fonts
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
This is a heading
PROF. YOGESH DESHMUKH www.dacc.edu.in
DNYANSAGAR ARTS AND COMMERCE COLLEGE, BALEWADI,PUNE – 45
This is a paragraph.
<!DOCTYPE html>
<html>
<head>
<style>
p{
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
</body>
</html>
This is a heading
This is a paragraph.
This is a paragraph.
This is a paragraph.
CSS Margin
The CSS margin property defines a margin (space) outside the border:
Example
<!DOCTYPE html>
<html>
<head>
<style>
p{
margin: 50px;
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
</body>
</html>
This is a heading
This is a paragraph.
This is a paragraph.
This is a paragraph.
the id Attribute
To define a specific style for one special element, add an id attribute to the element:
then define a style for the element with the specific id:
<!DOCTYPE html>
<html>
<head>
<style>
#p01 {
color: blue;
</style>
</head>
<body>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
</body>
</html>
This is a paragraph.
This is a paragraph.
I am different.
Note: The id of an element should be unique within a page, so the id selector is used to
select one unique element!
====================================================
To define a style for special types of elements, add a class attribute is apply to the
element:
then define a style for the elements with the specific class:
Example
p.error {
color: red;
<!DOCTYPE html>
<html>
<head>
<style>
p.error {
color: red;
</style>
</head>
<body>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
</body>
</html>
This is a paragraph.
This is a paragraph.
I am different.
This is a paragraph.
I am different too.
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript in Body</h2>
<p id="demo"></p>
<script>
</script>
</body>
</html>
Using innerHTML
The id attribute defines the HTML element. The innerHTML property defines the HTML
content:
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = 5 + 6;
</script>
</body>
</html>
Using document.write()
<!DOCTYPE html>
<html>
<body>
<script>
document.write(5 + 6);
</script>
</body>
</html>
Using window.alert()
<!DOCTYPE html>
<html>
<body>
<script>
window.alert(5 + 6);
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<script>
alert(5 + 6);
</script>
</body>
</html>
Using console.log()
For debugging purposes, you can call the console.log() method in the browser to
display data.
<!DOCTYPE html>
<html>
<body>
<script>
console.log(5 + 6);
</script>
</body>
</html>
JavaScript Variables
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Variables</h2>
<p id="demo"></p>
<script>
var x = 5;
var y = 6;
var z = x + y;
document.getElementById("demo").innerHTML =
</script>
</body>
</html>
Global Scope
<!DOCTYPE html>
<html>
<body>
PROF. YOGESH DESHMUKH www.dacc.edu.in
DNYANSAGAR ARTS AND COMMERCE COLLEGE, BALEWADI,PUNE – 45
<h2>JavaScript Scope</h2>
<p id="demo"></p>
<script>
myFunction();
function myFunction() {
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript const</h2>
<p id="demo"></p>
<script>
try {
const PI = 3.141592653589793;
PI = 3.14;
catch (err) {
document.getElementById("demo").innerHTML = err;
</script>
</body>
</html>
JavaScript Operators
JavaScript Arithmetic Operators
<html>
<body>
<h2>JavaScript Operators</h2>
<p id="demo"></p>
<script>
</script>
</body>
</html>
<html>
<body>
<h2>JavaScript</h2>
<p>When adding a number and a string, JavaScript will treat the number as a
string.</p>
<p id="demo"></p>
<script>
var x = 16 + "Volvo";
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>
JavaScript Strings
Strings are written with quotes. You can use single or double quotes:
Example
var carName1 = "Volvo XC60"; // Using double quotes
var carName2 = 'Volvo XC60'; // Using single quotes
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Strings</h2>
<p>Strings are written with quotes. You can use single or double quotes:</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
carName1 + "<br>" +
carName2;
</script>
</body>
</html>
JavaScript Numbers
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Numbers</h2>
<p id="demo"></p>
<script>
var x1 = 34.00;
var x2 = 34;
var x3 = 3.14;
document.getElementById("demo").innerHTML =
</script>
</body>
</html>
JavaScript Booleans
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Booleans</h2>
<p id="demo"></p>
<script>
var x = 5;
var y = 5;
var z = 6;
document.getElementById("demo").innerHTML =
(x == y) + "<br>" + (x == z);
</script>
</body>
</html>
JavaScript Arrays
The following code declares (creates) an array called cars, containing three items (car
names):
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Arrays</h2>
<p>Array indexes are zero-based, which means the first item is [0].</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = cars[0];
</script>
</body>
</html>
JavaScript Functions
==================================================================
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Functions</h2>
<p>This example calls a function which performs a calculation, and returns the
result:</p>
<p id="demo"></p>
<script>
return p1 * p2;
</script>
</body>
</html>
Function Return
When JavaScript reaches a return statement, the function will stop executing.
If the function was invoked from a statement, JavaScript will "return" to execute the
code after the invoking statement.
Functions often compute a return value. The return value is "returned" back to the
"caller":
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Functions</h2>
<p>This example calls a function which performs a calculation and returns the
result:</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = x;
function myFunction(a, b) {
return a * b;
</script>
</body>
</html>
JavaScript Events
HTML Events
An HTML event can be something the browser does, or something a user does.
HTML allows event handler attributes, with JavaScript code, to be added to HTML
elements.
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<script>
function displayDate() {
document.getElementById("demo").innerHTML = Date();
</script>
PROF. YOGESH DESHMUKH www.dacc.edu.in
DNYANSAGAR ARTS AND COMMERCE COLLEGE, BALEWADI,PUNE – 45
<p id="demo"></p>
</body>
</html>
JavaScript Strings
Example
var x = "John Doe";
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Strings</h2>
<p>Strings are written inside quotes. You can use single or double quotes:</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
</script>
</body>
</html>
JavaScript Arrays
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Arrays</h2>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = cars;
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Arrays</h2>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = cars;
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Arrays</h2>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = cars;
</script>
</body>
</html
CLIENT SIDE
SERVER SIDE
ADVANTAGES OF JAVASCRIPT.
Speed: Client-side JavaScript is very fast because it can be run immediately within
the client-side browser
Rich interfaces: Drag and drop components or slider may give a rich interface to
your website.
DISADVANTAGES OF JAVASCRIPT
Client side Javascript does not allow the reading and writing of files.
Integer types
Primitive Datatype:
Non-Primitive data types refer to objects and hence they are called reference
types. Examples of non-primitive types include Strings, Arrays, Classes, Interface,
etc. Below image depicts various non-primitive data types.