O Level M2 R5 Study Material & Objective Question Bank English Medium
O Level M2 R5 Study Material & Objective Question Bank English Medium
'O'level
Module-2[M2-R5]
Web Designing &
Publishing
Study Material &
Detailed Syllabus
5
1 INTRODUCTION TO WEB DESIGN
M2R5 6 YCT
1.1(iii) Applications of Internet: ● In terms of finding a new job, you can search and
The services received through internet are called apply for many jobs in a very short time.
internet services. Internet services are as follows–
● Communication: Contacting through internet has Disadvantages of internet– Internet is a main
become easy, fast and cheap. In the Internet, one can assistant of human life. As many advantages, its
communicate with more than one person disadvantages are also seen–
simultaneously through e-mail, chat etc. ● Many businesses use email to market their products.
● Education– There have been many changes in the They send spam messages to our e-mail inbox. Many
field of education through the Internet. People can get times important e-mails get deleted due to spamming.
information about any topic through internet. ● There is a lot of wrong information available on the
Education can be obtained from home through virtual internet.
classes. ● A lot of time is wasted while surfing the internet.
● Business: There has been also a revolution in the field ● There is a danger of malware or virus, it removes all
of business through the Internet. With this, maximum the important files of the computer and the system
profit can be earned by business on a larger scale. crashes
● Entertainment: Through internet one can entertain at ● Internet distracts students.
home by downloading any movie, song etc. ● Internet reduces work productivity.
● Online Transaction: Online transactions can be using ● Due to excessive use of internet, one has to face health
the Internet. This is an easy way to do transactions related problems like migraine, effect on eyesight,
sitting at home. back pain, weight gain, depression etc.
● E-commerce: We can buy and sell anything online ● Important files can be easily taken by hackers.
through the internet. There are a huge number of web Hacking can take place to extract personal information
portals available for buying and selling. from people’s e-mail accounts, bank accounts and
mobile phones.
1.1(iv) Applications of Advantages or
● Pornography easily available into the hands of even
Disadvantages Internet: small children through the Internet.
Internet has become a necessity today, and we have ● Sometimes you end up spending too much while
felt this need because of the benefits we get from it. shopping online on the internet.
Advantages of internet– 1.1 (v) How Internet Works?:
● Through the Internet we are able to access various Internet is a type of interconnected network of many
types of online services. computers which are connected to each other through
● Important documents like Aadhar Card, PAN Card, various mediums. All these computers which are
Ration Card and Voter ID can be obtained online. connected to the Internet are divided into two types on
● Through social media sites, you can stay connected the basis of their function. One is called server and other
and communicate with your family, relatives, friends is called client. Both server and client are types of
and can also share photos and videos of events. computers which connect to each other through the
● From your phone you can pay water bill, electricity Internet, but the function of the server is to provide
bill, train ticket, hotel booking, taxi booking etc. Internet service and the client is the computer which
● Tasks like admission in college, filling forms for connects to the server through the Internet and receives
competitive examinations, submitting scholarship service. Like we use computers to explore the Internet or
forms can be completed without going to the to use various Internet services. Therefore, our computer
government office. will be considered a client computer in the Internet. At
● If you want to get detailed information about any new the same time, a server is also a computer but it is used
topic, the Internet is beating the library in this matter. as a server, in simple language, it is used as storage. This
You can get information about any topic within a computer is also connected to the Internet like our
minute. computer i.e. the client. Generally, web content is saved
M2R5 7 YCT
in these computers. When a client needs web content, the WWW (World Wide Web) is also called Web. This
client computer obtains that content by making a is the most popular service available on the internet. It is
connection to the server. This process is facilitated by thea huge group of information interconnected through
web browser and several Internet protocols. Whatever hyperlinks which can be accessed on the Internet with
we see on the Internet like website, video, image, song, the help of a web browser. It is the second most popular
movie etc are stored on any server. To show or use all Internet service after e-mail.
this content on the Internet, our computer (client) makes World Wide Web is a system that is connected to
a connection with that server and start communicating many computers with the help of Hyper Text documents.
It connects information together and to send this
among them selves. After which our computer receives
information from one place to another, Hyper text
the data from that server and shows it as per our
transfer protocol is used which exchanges data with the
instructions. When two computers connect together then
help of hyperlink.
they use TCP/IP to communicate with each other. The
Every page stored on the World Wide Web is called a
full name of TCP is Transmission Control Protocol. It
web page which is created using HTML (hyper text
transfers information or data in the form of small packets markup language).
from one computer to another. The full name of IP The World Wide Web is based on the client/server
(Internet Protocol) is Internet Protocol. It works as the model. The computer providing Internet service is called
address of the computer, that is, it tells the location of the
Web server and the user of this service is called Web
computer. Every computer throughout the Internet has its Client. Client Software is called web browser which runs
own Internet protocol. With its help, every computer on on the local computer.
the Internet can be identified, due to which information Server software runs on a web host, takes an
or data can reach the right computer. Internet connection and then launches a web browser to
That is, TCP transfers information or data in the access the web.
form of small packets and IP transmits that information 1.2(i) Difference between World Wide Web
or data to the right computer. It may have taken you time & Internet:
to read this and understand each process, but it is so fast
Internet (www) World Wide
that here you send the information and it gets there.
Web
Generally it depends on the speed of your internet data or
The estimated year of The World Wide Web,
internet connection. For example, you can take
origin of the Internet is Started in 1993.
WhatsApp which is very popular in India for messaging. 1969, although the
Similarly, communication takes place through the opening of the network to
internet and this is how the internet works. Because all commercial interests
the content present on the Internet is stored somewhere began only in 1988.
on another computer, like if they run a website then that The name of the first First version of the
website is stored on a server. version of the Internet World Wide Web is
1.2 WWW : was ARPANET. called NSFnet.
The Internet is a global system of interconnected Internet is a network of It holds files, folders
computer networks that connect various small and large computers, in which and documents stored
computer networks spread across the world. Personal, copper wire, fiber optic in different computers.
public, educational, business and government networks cable and wireless
etc are connected to it. It uses a common set of protocols network are used.
for data transmission known as TCP/IP. Primary This works by internet It works through
objective of internet is to ease the transmission of protocol. Hyper text transfer
information. Many different tools are used on the Protocol (HTTP).
Internet to make this possible. E-mail, newsgroup, telnet, It is base and It depends on the
gopher, FTP and wide area network are important tools. independent of the World Internet to function.
The World Wide Web (WWW) is the most popular Wide Web.
Internet tool. This is hardware. Its form is software.
M2R5 8 YCT
1.2(ii) Evolution of the www: can be used in operating systems like Windows, Linux,
www is a group of documents which are linked to Macintosh etc. It can also be downloaded from its
each other by hypertext. In hypertext document, Text official website.
Image, sound etc are included. www is a service of Opera– Opera is a free internet browser available
internet. www was first used by TIM BERNERS LEE at for mobile phones and computers. It includes features
CERN laboratory in 1989. In the World Wide Web, like tab browsing, page zooming, mouse gestures and an
information is stored in the form of websites. This integrated download manager etc. Opera comes pre-
website is stored on web server in the form of hypertext designed with a free Virtual Private Network (VPN) that
files. The World Wide Web is a system by which each works on both private and public free internet and
website is given a unique name. That is identified on the protects your location from hackers. Opera’s VPN blocks
web by the same name. your location when using the public Internet, providing
The full name of www is World Wide Web. Internet additional protection against malware. The Opera
and World Wide Web are connected closely and both are Portable browser which is, available for Windows, stores
dependent on each other. The World Wide Web is a your browsing history, bookmarks extensions and other
storage of information, which is in the form of links. private data on a portable storage device such as a USB
Actually, it is a technology due to which computers drive.
arround the world are connected to each other. The
Google Chrome– This is a web browser developed
World Wide Web works on HTML, HTTP, web servers,
by Google Company in 2008 which is becoming popular
and web browsers.
for its fast speed and better security provisions. It is a
1.2(iii) Web Browsing Software: web browser released primarily for Microsoft Windows.
A web browser is a software application that allows
■ To open Microsoft Edge;
a user to view and display web pages. Text and images
can be a hyperlink presented on a web page which can be • Click the Microsoft Windows icon on the taskbar.
clicked to move another web page easily. Web browsing
software is a client of an Internet server that is provided
free of cost by Microsoft Corporation and many other
companies. Through this, any information can be sent,
received or retrieved on the Internet. When URL is given
to web browser it identifys the location of the requested
page.
Following are some of the famous web browsers–
Microsoft Internet Explorer– It is a popular web
browser which is manufactured by Microsoft Company.
It is also a type of Windows component which is used to
access and navigate web pages.
Figure-1.2 Selecting Microsoft Edge
Internet Explorer supports HTML4.01, CSS Level 1,
XML 1.0 and DOM Level. It is the default browser of
Windows which is now replaced by Microsoft edges. Following are the parts of Microsoft Edge–
Microsoft Edge– This is the latest web browser of Title bar– It is located at the top of the Internet
Windows 10. Internet Explorer 11 is also available with Explorer window, displays the name of the current web
Windows 10 for compatibility. The browser includes page. Minimize, Maximize and Restore buttons are
integrated Adobe Flash Player and a PDF reader. Web displayed on the right side of the title bar.
user can make annotations on pages that can be stored Address bar– It displays the address of the web
with a drive, But can not save HTML pages. page you are currently viewing. You can also use the
Mozilla Firefox– It is a free open source web address bar for navigation. Type the address of the page
browser which is developed by Mozilla Corporation. It you want to visit in the address bar and press Enter.
M2R5 9 YCT
There are following buttons– display the Internet addresses of files on client computers
• Back: Displays pages from the list of previously connected to the Internet.
viewed pages. Enter the web page address you want to visit on the
• Forward: Displays a page from the list of next address bar.
viewed pages. To type a web page address,
• Stop: Stops the downloading of the current page. • Click on the address bar.
• Refresh: Displays the updated version of the current • Type the web page address.
web page. Lik– https://www.featurepics.com
Reading View– Click on the book icon to go to
reading mode. It displays a clean view of the main
content of the page by removing distraction.
Reading List– This allows to save web pages for
later viewing. Such as in the Favorites folder, you can
also add web pages to the reading list.
Pinning sites to the Start menu– Open your
favorite website and click the Settings button. Now click
on "Pin to start" option from the displayed settings menu.
Now your favorite website will be displayed on the start
menu. Figure-1.3 Typing an address in the address bar
Sharing– Regularly opened web pages can be • The web page is displayed as shown below.
shared by sending a link.
Advanced Tab Management Options in Edge
Browser– Edge has focused on tab browsing in tab
management options. Right click on any browser tab.
Due to which a context menu option will be displayed.
This can be used to refresh tabs reopen a closed tab.
Close all tabs etc.
1.3 Website:
A website is a collection of web pages related to a
particular person or organization, found under a single Figure-1.4 FeaturePic homepage is displayed
domain name. Different pages of the website are Internet Addressing Scheme– Many computers are
connected to each other through hyper links. connected together on the Internet. But for
A website may contain a few or many webpages. communication, every connected computer is provided a
The steps to connect to a website are as follows– unique address which is called IP addressing system. IP
• Type the URL of any website in the web browser address is an address that is used to uniquely identify a
like– www.youthcompetitiontimes.com device on an IP network. The directory system available
• The browser attempts to connect to the web server. in IP addressing is called Domain Name System (DNS)
• The web server accepts the request. which converts a name into a numeric address.
• The homepage of a website is downloaded from a 1.3(i) Protocol:
web server on your personal computer. Protocol is a set of rules used for digital
• The web page is displayed by the web browser and communication. The protocol decides how data will be
the connection is closed between the server and your transmitted and received over the computer network.
browser. There are several levels of protocols available in a
Website Address– Web address is also called URL. telecommunications connection.
It identifies the location of a specific web page. URLs Following are the common networking protocols–
M2R5 10 YCT
FTP (File Transfer Protocol)– FTP protocol is a connectionless protocol that transfers data over the
standard for transmitting files between computers over network. This protocol does not ensure that data reaches
the Internet protocol. Transferring or copying files from the destination properly. Therefore, it is used only in
one place to another over the network is possible only those situations where data security is not important but
through the FTP protocol. FTP uses port 21 for transmission speed is important.
connection control and port 20 for connections. Gohper– Gohper is an application-layer protocol
HTTP (Hyper Text Transfer Protocol)– It is a that provides the ability to search and view web
stateless protocol i.e. all requests sent by the client are documents stored on remote web servers. It works on
Executed separately and after responding to the client/server principal.
request the connection is closed. 1.3(ii) Domain Name:
TCP– Transmission Control Protocol is used for It is a set of network resources that are assigned to
communication in a network. It converts the message users. Through this, computers which are connected to
into a set of packets at the sender. It is also called
the Internet, are identified and located. Domain name is
connection oriented protocol and it is an important
always unique and written separated by dot (⋅).
protocol which works at the transport layer of OSI.
Example– google.com, yahoo.com etc.
POP– Post Office Protocol is used to receive e-mail.
The Domain Name System is used to identify
Because POP is in version 3, it is called POP3. This
servers and translates domain names into IP addresses. It
protocol works at the application layer of the OSI model
is a two-letter abbreviation denoting the name of a
that allows clients to download and send mail from the
server. Once the e-mail is downloaded, it can also be country and a three-letter abbreviation denoting the name
read offline. of an organization.
SMTP– Simple Mail Transfer Protocol is a standard Following are some of the key identifiers–
protocol used for e-mail service over TCP/IP networks. .com – Commercial business
This protocol helps in sending e-mail messages. SMTP .edu – Educational Institutions
protocol works at the application layer of the OSI model. .org – Organizations
It helps in transmission and delivery of e-mail over the .gov – Government entities
Internet. It is used for e-mail applications in the same .net – Internet service provider
network as well as in different networks. .info – Information services
IP– Internet Protocol, also known as TCP, was
1.3(iii) Web Server:
developed in the 1970s. It is an addressing protocol that
Web server is a software that delivers web pages to
allows different computers to communicate with each
users and serves web pages to visitors. Web server is the
other by establishing a network. It maintains the
program of any website which performs the task of
addresses of packets based on each standard and knows
the source and destination of each IP packet. searching the web pages of that website. Generally, the
software that delivers web pages to its users, is called
Telnet– Telnet is a set of rules for connecting one
web server. It helps in searching any website data with
system to another. The connecting process in this is
called remote login. Entering the user name and the help of HTTP Protocol.
password starts the Telnet session. The computer Types of Web Server–
requesting the connection is called the local computer • Apache Web Server
and the computer accepting the connection is called the • Internet Information Server
remote computer. • Nginx Service Server
WAP– Wireless Application Protocol provides • Light Speed Web Server
services to web browsers. It is a browser used in mobile
1.4 How Website Works:
devices.
UDP– User Datagram Protocol is a transport layer Figure-1.5 below shows the travel of web pages
protocol for client server network applications. It is a through networking equipment and telecommunication
systems.
M2R5 11 YCT
for information. A web page can contain text, images,
graphs, audio, video or hyperlinks.
Every web page has a unique address called a URL
that identifies its location on the network. Web pages are
of two types: static and dynamic. Static web pages have
the same content every time when they are accessed, and
dynamic web pages change content every time it is
accessed.
Figure-1.5 shows the travel of web pages through
the networking equipment and telecommunication To open a web page,
systems of the Internet. • Type the URL in the search bar of the browser.
In the web browser, a page can be visited by • After typing, press Enter or Ok button.
typing a URL or clicking on a link. The URL takes the • The web page starts displaying.
user to the appropriate location to provide the desired
1.5(i) URL (Uniform Resource Locator):
information. URL (Uniform Resource Locator) is the
Uniform resource locators (URLs) are used to
name of a web location, through which web browsers
specify addresses on the World Wide Web. It provides
and web servers are able to communicate with each
network identification for any resource connected to the
other.
web.
A URL consists of several parts. The first part
Any document or page available on the World Wide
contains the name of the transfer protocol (http) followed
Web can be easily accessed using URL.
by a colon and two slashes (://). In the second part, the
name of the server is known, it is also called the domain The format of URL is as follows–
name of the host computer which is www. The third part Protocol://host name/other_information
identifies the web server for connection. Its last part For example,
contains google.com to identify the specific directory, http://featurepics.com
document and other objects on the web server. In its last The protocol in a URL describes how information is
part, specific directories, documents and other objects are transferred through the link. The protocol used for web
identified on the web server. resources is Hypertext Transfer Protocol (HTTP). Apart
http://
← →← www →←
google.com/
→← index → from this, HTTPS, FTP, Telnet, Newsgroup and Gopher
Part I Part II Part III Part IV protocols are also used in most web browsers.
The protocol is followed by a colon (:), two slashes
Figure-1.6 Example of URL
(//) and then the domain name. The domain name itself
Internet routers examine requests to determine
tells the location of the resource. After the domain name,
which server the request is intended for. URL, it is sent
there are links to files or subdirectories.
to the Internet on a Web Server. Tells which request is
Absolute URL– An absolute URL contains all the
being searched, if a valid request is returned on HTTP://.
information needed to locate a resource available on the
By receiving the request through the HTTP
Internet. This is a complete path including the domain
protocol, the web server tells which document has
file name.
requested by the user.
Example–http://www.sparkpay.com/images/img.jpg
When the requested document or object is
It locates the image file named img.jpg which is
received on the main page of the server, then this home
available in the Images directory and has the domain
page sends that document back to the client which is
www.sparkpay.com.
displayed on the computer screen.
Relative URL– A relative URL usually contains
1.5 Web Page: only the path to a particular file, which is relative to the
A web page is an electronic page created by using absolute URL.
HTML (Hyper Text Markup Language). It provides links Example– http://www.domain.com/default.html
M2R5 12 YCT
an example of a relative URL. 1. Client Side Scripting Language– Client side
Through this you can easily create a set of hypertext scripting is used to generate a code that can run on a
documents. Connect them together by hyperlink through browser (client end) without the need for server side
file name. So that the user can go to another file while processing. This type of script is placed inside an HTML
reading a document by clicking on the file name document. It is usually associated with a language that is
available in it. compatible with the browser. HTML, CSS and
JavaScript languages are used for client side but
1.6 Front End:
JavaScript is the most used language for client side
Front end and back end are very important units
scripting. It has the ability to run on any browser. The
used in web development– front end is also called client
browser downloads that code permanently and processes
side and sometimes it is considered as web design.
it without a server. Scripting is used to check a user’s
The front end of a website is what we can see and form for errors before additional information is required
interact with on the browser. That is, it is a part of the and to change the content according to user input.
website by using this users interact directly. It is created
Client Side Scripting Languages–
by combining technologies such as Hyper Text Markup
• HTML: It provides the frame to the website and
Language (HTML), JavaScript, and Cascading Style
describes content management.
Sheets (CSS). Front end developers create and design the
• CSS: It provides a way to design graphic elements
buttons, menus, page links, graphics, and more elements
that help in making the appearance of a web
on a web page. This enables User to access and request
application more attractive.
features and services of the underlying Website.
• JavaScript– It is essentially client side scripting
1.7 Back End:
designed for specific purpose but currently various
The back end of the web industry is called the client JavaScript frameworks are used as server side
side. The back end and server side are the parts of the scripting technology.
website that you don’t see. People who work on the 2. Server-Side Scripting Language– Server side
backend are called programmers or developers. The back scripting creates a way for the website to work with the
end developers are mostly responsible for security, database and backend, which organizes and runs the
structure and content management. It establishes website. Server side scripting is a programming
communication between the server side of an technique for creating code that can run software on the
application, the database, and the browser. It stores and server side. Server side scripting creates the
manages data and everything is created on the client side communication link between the server and the client.
of the website. This is the part of the website that you Server side includes three parts – server, database, API
can only view but can not interact. Must have some skills and back end software, which is developed through
in back end programming language or framework, server side scripting language.
accessibility and security, understanding of front end Server Side Scripting Languages–
technology like HTML, CSS and hosting management
• PHP: This is the most popular server-side language
ability. used on the web, which was designed to extract and
The backend part is built using to a few languages manipulate information from databases. It is used in
like PHP, C+, Java, Python, JavaScript etc. Facebook, WordPress and Wikipedia.
1.8 Client and Server Scripting Language: • Python: It works well in object oriented
A script is a type of program in which a number of environment and used in famous sites like YouTube,
programming instructions, i.e. code, are written, which Google etc.
are interpreted at runtime. This means that when an • RUBY: It is a complex logic language that packages
application is running, the code is read and executed. a back end with database utility, which is also
Scripting languages can be embedded within HTML provided by PHP and SQL.
itself. Apart from this ASP.NET, Cold Fusion, C#, Java,
All websites generally run on two components– C++ etc are server side scripting languages.
M2R5 13 YCT
Difference between client and server side 2. Flexible Visuals– Unless all the components of
scripting language– Following are the important the page are flexible, it cannot render well on the
differences between client side scripting and server side browser. Images also have to be flexible so that they can
scripting– adjust to almost all screen sizes. The use of flexible
visuals makes the media scalable by changing the media
⇒ Client side scripting works on the front end and is
size and view port size.
visible to the user whereas server side scripting
3. Media Queries– CSS media queries allow
works on the back end and not visible on the client
targeting certain device classes as well as inspecting the
end.
user's device physical features. You can display the
⇒ Client side scripting is when the browser contains all layout in different ways using media queries.
the code and the page is later changed according to
1.10 Types of Website:
the user's input. Server side scripting occurs when
A website is a collection of many web pages. A
the user's browser initiates a server request. Non-
website contains many web pages and each page has
dynamic pages are created based on several
different types of information. There are mainly two
conditions. types of websites– 1. Static website, 2. Dynamic website.
⇒ The browser can perform client side scripting after 1. Static Website– A static website represents a
accessing the page sent by the server. The server can collection of web pages whose content is fixed and is
perform a server side script but cannot perform same for every user.
client side scripting. Advantages–
⇒ Server side scripting helps to connect to databases • It is made by coding with simple HTML.
that already exist on the web server. Client side • It loads fast on any web browser.
scripting does not connect to the database available • The cost of creating a static website is very cheap.
on the web server. • Saves time.
⇒ The scripting process for the server side is done on a • It can get dedicated servers also at low cost.
remote computer. Therefore the response from the Disadvantages–
client is relatively slow compared to the request. In • Its content cannot be changed easily unless its code
server side scripting, the response is faster because is changed, its content also does not change.
the script is executed on the local computer. • These are not suitable for long periods of time.
⇒ Languages used in server side are Ruby, PHP, ASP • It contains non-interactive web pages.
Python, C# Java, C++ etc. Generally languages like • Complex tasks like transactions cannot be done in
HTML, CSS, Java Script etc. are used for client side web pages.
scripting. 2. Dynamic Website– A dynamic website is a set of
1.9 Responsive Web Design: web pages whose content changes dynamically. A
Responsive web design is a process in which a dynamic website accesses data from the database, so
website is designed in such a way that it adjusts its layout when the content of the database changes, the content of
according to screen size and orientation on desktop, the website also changes. It is written in server side
coding languages like PHP, ASP, JSP, Ruby etc.
laptops, tablets, and small-screen mobile devices.
Advantages–
Using a responsive website is also liked by mobile
visitors as the webpage does not take much time to open • It is easy to add content to the website even without
using coding.
and the speed of the site is further improved.
• Dynamic websites contain interactive web pages.
Responsive website design has the following three
main elements– • It is easy to use in online stores, social media
platforms etc.
1. Fluid Grids– The size of the elements of most
websites is set in pixels, which is fixed, but according to Disadvantages–
Fluid Grid, the height and width of the website layout is • Creating a dynamic website costs more.
defined in percentage instead of pixels so that it can fit • Security issues and risks are high.
on any screen. You can resize your height and width
according to the size. • There is more complexity in developing them.
M2R5 14 YCT
Practice Questions with Explanatory Solutions
1. Browser is– (a) IPVI (b) IPV2
(a) Line, which delineates the edge of a (c) IPV6 (d) 1PV4
programming window. Ans.(d) IPV4 is the most used Internet protocol which
(b) Device, which is used to modify the window. was developed in 1970. This is the fourth version of
(c) Software programs specifically designed for the Internet Protocol. An IPv4 address is 32-bit.
viewing web pages on the Internet. 192.168.0.1–192.168.0.255 range can be easily
(d) None of these. identified. Each three-number group can contain
Ans.(c) Web browser is a software which helps you in numbers from 0-255. It is used to deliver data packets
viewing the content available on the internet like in the network from the host device to the destination
blogs, articles available on websites, images, videos, device.
audios etc. Tim Berners Lee created the first web 8. What is Cookie?
browser in 1991, which was named World Wide Web. (a) Computer code used to show animation and
Some of the major and popular web browsers are play sound.
Mozilla Firefox, Internet Explorer, Safari, Google (b) Computer code that automatically records all
Chrome Opera, Epic etc. user transactions.
2. On which model is www based? (c) An advertisement displayed on the user’s
(a) Local Server (b) Client Server screen.
(c) 3 tier (d) None of these (d) Information sent to a computer which is
Ans. (b) The full form of www is World Wide Web. It used to return information to the website being
is a collection of websites or web pages, stored in a accessed.
web server and it is connected to local computers Ans. (d) Web cookies are text files that are sent by the
through the Internet. It is based on the client server server to the browser. This file is sent back to the
model. The client is a web browser that communicates server by the browser all the time so that it can remain
with the web server that hosts website. connected to the server. Web cookies are used for
3. A web robot in a web crawler is– security and user information. This is information sent
(a) Crawler robot (b) crawl bot to the computer, which is then used to return
(c) Web bot (d) Web robot information to the visited website.
Ans.(c) Crawler is a program that reads the webpages 9. The first page of the website is called–
of a website and sends the details of the webpages to (a) Design (b) First page
the search engine so that the search engine can add (c) Home page (d) Main page
that webpage in its database. A web bot is a web robot Ans.(c) The first page of the website is called the
in a web crawler. homepage where visitors can find hyperlinks to other
4. How many bits does the IP address have in IPv4? pages of the site. That is, the home page is the starting
(a) 16 bits (b) 64 bits page of a website, which is the “point of entry” for all
(c) 128 bits (d) 32 bits the information stored on it.
Ans.(d) Full name of IPV4 is Internet Protocol 10. Software that prevents external access to a
Version 4, it is the fourth version of Internet Protocol. system is called–
It is a connectionless protocol used in packet switched (a) Gateway (b) Firewall
layer networks such as Ethernet. (c) Intution Prevention System (d) Anti-Virus
5. Which of the following is a web server? Ans. (b) Firewall is software that acts as a network
(a) Mozilla Firefox (b) Postfix security system whose job is to protect a computer
(c) Bind (d) Apache network from external access. It is installed at the
Ans. (d) Apache is an open source and free web gateway of the computer network and filters the traffic
server software that provides HTTP server services. going in and out of the network.
HTTP server is such server software, which saves and 11. What is the full form of HTTP–
hosts web pages and website files. Apache Server (a) Hyper Text Transfer Protocol
supports various operating system platforms like (b) HTTP Text Transfer Protocol
Windows, Linux, Macintosh etc. Apache server (c) High Transfer Tier Program
software can host both static and dynamic websites. (d) HTML Type Transfer Protocol
6. The applet is– Ans. (a) The full form of HTTP is Hyper Text
(a) Image displayed on a web page Transfer Protocol. This is a type of network Protocol
(b) HTML program (c) Security protocol that is used in the World Wide Web. HTTP uses a
(d) A program to be embedded in another server-client model. It is a protocol for transferring
application. information over the internet.
Ans.(d) Applet is a special type of computer program
whose purpose is to run (Embed) inside another 12. Connecting the website to the backend, processing
software application. An applet is a Java program that data and controlling the behavior of the top
runs in a web browser. layers, etc is all done by whom?
7. Which version of Internet Protocol is most used (a) HTML language (b) Javascript
on the Internet? (c) CSS Scripts (d) None of these
M2R5 15 YCT
Ans. (b) Java Script is a dynamic computer language. Ans.(a) Static web page is stored in the web server
It is also an interpreted/oriented language. Java script and loaded in the client’s browser. These webpages
client also known as side/server side scripts. can only be read by the user and no modification can
Connecting the website to the backend, processing be done by the user. This web page only holds static
data and using the top layers. All the work like information and loads the same content every time it
controlling behavior etc is done through JavaScript. is reloaded. Static web pages can be created only
13. Telnet is– using HTML. A static web page is created only when
(a) Terminal network we do not have to make any changes to it later.
(b) Telecommunication network 20. The function of modem is–
(c) Telephone network (d) Local network (a) Modulation (b) Demodulation
Ans.(b) Telnet is a network communication protocol, (c) Both (a) and (b) (d) None of these
which is used to communicate and manage various Ans. (c) The full form of modem is
devices present on the network such as servers, modulator/demodulator. It is a hardware component
computers, routers, switches and firewalls etc. This is that allows a computer to connect to the Internet.
completely command based communication. Modem is used to send data to the computer via
14. TCP is a commonly used protocol in– telephone or cable. It converts analog and digital data
(a) Application layer (b) Transport layer for two-way network communication in real time.
(c) Network layer (d) Physical layer 21. Pieces of information sent over the Internet–
Ans. (c) TCP means Transmission Control Protocol. It (a) Piece (b) Packet
transfers information between two computers and (c) Byte (d) None of these
makes transmission possible. It is generally used in Ans. (b) A small part of someone’s message on the
the transport layer. Internet is called a packet. Data sent over a computer
15. A website address is a unique name that identifies network is divided into packets. These packets can be
a specific…..... on the web. retrieved by the computer or device by reassembling
(a) Web browser (b) PDA them.
(c) Website (d) None of these 22. Protocol used to receive mail from remote
Ans.(c) The unique name used to identify a website on mailbox–
the web is called website address or URL. The web (a) IMAP (b) HTTP
address itself displays a website or a page of a website (b) POP3 (d) SMTP
or leads to a web page. Ans. (b) POP 3 (Post Office Protocol) is an Internet
16. Leader of the World Wide Web Consortium– standard protocol used by local e-mail software clients
(a) Mark Zuckerberg (b) Elon Musk to receive e-mail from remote mail servers over a
(c) Tim Berners Lee (d) None of these TCP/IP connection.
Ans. (c) World Wide Web Consortium (W3C) is an 23. IP protocol is an implementation of which layer
international community. It has many members, of OSI?
organizations, and experts who work together to (a) Network layer (b) Physical layer
establish standards for the World Wide Web. It was (c) Data Link Layer (d) None of these
led by Tim Berners Lee. Ans.(a) The IP protocol is an implementation of the
17. The address of a permanently assigned router network layer of OSI. It is the third layer of the open
connected to the Internet is called– system interconnection model whose main function is
(a) Dynamic IP address (b) Static IP address routing and delivering data packets from one host to
(c) Mixed IP address (d) None of these another between different networks.
Ans.(a) A dynamic IP address is an IP address that is 24. The protocol used to access the Internet is–
automatically assigned to each node or connection in (a) SLIP (b) POP
the network—like your smartphone, desktop PC or (c) IMAP (d) SMTP
wireless tablet. Dynamic IP addresses keep changing Ans.(a) The full name of SLIP is Serial Line Internet
with time in the network. Dynamic addresses are Protocol. SLIP is an Internet protocol through which
assigned as needed by Dynamic Host Configuration users can access the Internet using a computer
Protocol (DHCP) servers. modem.
18. Netscape Navigator has been developed by– 25. What is the other name for front end?
(a) Server side (b) Client side
(a) Microsoft (b) Google
(c) Receiving Office (d) None of these (c) Both (a) and (b) (d) None of these
Ans. (b) Front end is also called client side and
Ans. (d) Netscape Navigator was first commercially sometimes it is considered as web design. The front
successful web browser. It was based out of the end of the website is what we can see on the browser
Mosaic browser and was created by a team led by and can also interact with it. That is, it is a part of the
Mark Andreesen. Netscape Navigator helped website that users interact with directly. It is built by
influence the development of the Web as a graphical combining technologies such as Hyper Text Markup
user experience rather than text based. Language (HTML), JavaScript, and Cascading Style
Sheets (CSS). Front end developers create and design
19. Loads the same content every time the page is the buttons, menus, page links, graphics, and more
reloaded– elements on a web page. This enables the User to
(a) Static web page (b) Dynamic web page access and request features and services of the
(c) Both (a) and (b) (d) None of these underlying Website.
M2R5 16 YCT
2 EDITORS
M2R5 21 YCT
Practice Questions with Explanatory Solutions
1. Features of Sublime Text Editor are– 7. Which menu in Notepad has only two options,
(a) Column selection and multi select editing Word wrap and font?
(b) Syntax highlight and high contrast display (a) Format (b) insert
(c) Auto complete, code building, snippets (c) Edit (d) title
(d) All of the above. Ans. (a) Under the Format menu of Notepad, there are
Ans. (d) Sublime Text Editor is a cross-platform two options: Word Wrap and Font. Word wrap is an
source code editor with an application programming extremely useful command. Word wrap is used in
interface. It natively supports multiple programming Notepad to view text without scrolling.
and markup languages and can be added by the user Font color, font command is used to change the
with function plugins. Features like column selection, font style of the document, through this you can
multi select editing, syntax highlight and high contrast
display, auto complete, code building, snippets etc. are change the font size, font name etc. as per your
available in Sublime Text Editor. choice.
2. The extension of the file saved in Notepad 8. Compare plugin in Notepad++ helps to find out
document is– the difference between–
(a) ⋅txt (b) ⋅pnd (a) Two versions of files
(c) ⋅xmt (d) ⋅doc (b) Two versions of the folder
Ans. (a) Notepad is a simple but useful text editor (c) Applications
program, which is included in every version of (d) None of these
Microsoft Windows. Notepad helps users to create and
read plain text. Files prepared in this text editor are Ans. (a) Compare plugin is used to compare between
saved with ⋅txt extension. two versions of files in Notepad++.
3. What is not supported by Notepad? 9. There is no text editor–
(a) Read text (b) Write text (a) Notepad++ (b) Notepad
(c) Read and write text (c) Wordpad (d) Photoshop
(d) Graphics Ans. (d) Text editor is a software tool that edits text.
Ans.(d) Notepad is a simple but useful text editor Adding, deleting, changing, finding and replacing
program included in every version of Microsoft something new in the text is called text editing.
Windows. Notepad supports both read and write text. WordPad, Notepad and Notepad++ are text editors.
Graphics cannot be used in Notepad files. 10. Notepad++ supports–
4. What is not true about Notepad++? (a) Regular expression
(a) Proprietary text editor (b) Syntax highlighting
(b) free (c) Auto Complete
(c) open source (d) cross platform (d) All of the above
Ans.(a) Notepad++ is a free open source, cross Ans. (d) Notepad++ is a free source code editor that
platform text editor that is used in place of Notepad. supports multiple languages. Notepad++ supports
Notepad++ is written in C++ and uses the Win32 API syntax highlighting and syntax folding. It supports
and STL, ensuring high execution speed and small regular expressions and auto complete including word
program size. completion, function completion and function
5. Which platforms does Bracket text editor parameters indicate completion.
support? 11. The option used to save the Notepad window is–
(a) Mac OS (b) Windows (a) edit (b) save
(c) Linux (d) All of the above (c) format (d) save as
Ans.(d) Bracket text editor is used for Mac operating Ans. (b) Notepad is a simple text editor included with
system. It is open source and can be downloaded for versions of Microsoft Windows that allows you to edit
free. Brackets support multiple platforms like Mac plain text files. Allows to create, open and read. Save
OS, Windows, Linux etc. option is used to save the Notepad window.
6. It is a powerful text editor available for all 12. Which of the following is not available in the
platforms. Notepad menu bar?
(a) Emacs (b) Vim (a) file (b) edit
(c) Bluefish (d) IDLE (c) insert (d) format
Ans. (a) The text editor available with all platforms is
Emacs but it is most widely used on Unix and Linux Ans. (c) There are many options for editing text in the
platforms. It can be downloaded for free from the menu bar of Notepad which are called menus. Each
GNU site. Emacs, in addition to being a text editor, menu has a different use. File, Edit, Format, View and
can also issue shell commands, access the Internet, Help menus are available in the menu bar of Notepad.
write and test programs, etc. It can also read and send 13. HTML code can be written by using which of the
e-mail. It is a cross platform program and can run on following?
many operating systems like Windows, Mac Osx, (a) VLC media (b) Notepad++
Linux, Free BSD, SUN OS etc. (c) Microsoft PowerPoint (d) None of these
22
Ans. (b) Notepad++ is a text editor and source editor Ans. (b) Notepad is a simple text editor included with
application used by Windows computer users. HTML versions of Microsoft Windows that allows you to edit
code can be written using Notepad++. plain text files. Allows to create, open and read the
14. Notepad++ is a .......... software– option used to save the Notepad window is Save.
(a) Free and open source (b) Paid
(c) Trialware (d) Shareware 21. Which of the following is not available in the
Ans. (a) Notepad++ is a free and open source notepad menu bar?
software. Apart from the general features of a text (a) file (b) edit
editor, Notepad++ has features like syntax (c) insert (d) format
highlighting, autocompletion etc. for different
Ans. (c) There are many options for editing text in the
programming languages, making it very useful for
programming and scripting. menu bar of Notepad, which are called menus. Each
15. In Notepad++, highlight a block of code by menu has different uses. In the menu bar of Notepad,
commenting it out using the………… shortcut File, Edit, Format, View and Help menus are
key. available.
(a) Ctrl + O (b) Ctrl + Q 22. HTML code can be written using which of the
(c) Ctrl+H (d) Ctrl + G
following?
Ans. (b) Using the Ctrl + Q shortcut key, a block of
code in Notepad + is commented out and highlighted. (a) VLC Media (b) Notepad++
16. Extension of Wordpad file is– (c) Microsoft PowerPoint
(a) ⋅txt (b) ⋅rtf (d) None of these
(c) ⋅doc (d) ⋅text Ans. (b) Notepad++ is a text editor and source editor
Ans. (b) Microsoft WordPad is a rich text editor first application used by Windows computer users. HTML
introduced by Microsoft in Microsoft Windows 95 code can be written using Notepad.
and available in all subsequent versions. WordPad
uses rtf (Rich Text Format) file extension to save files 23. Notepad++ one. ………Software is–
by default but it can also save documents in docx (a) Free and open source
(Office Open XML), ODT (Open Document) formats. (b) tree
17. ........... is not text editor. (c) trialware (d) shareware
(a) Notepad++ (b) Notepad Ans. (a) Notepad++ is a free and open source
(c) Wordpad (d) Photoshop
software. Apart from the general features of a text
Ans. (d) Text editor is a software tool that edits text.
editor, Notepad++ has features like syntax
Adding, deleting, changing, finding and replacing
something new in the text is called text editing. highlighting, autocompletion etc. for different
Wordpress, Notepad and Notepad++ are text editors. programming languages, making it very useful for
18. Notepad++ supports– programming and scripting.
(a) Regular expression (b) Syntax highlighting 24. In addition to Preferences, what else can be used
(c) Auto Complete (d) All of the above
to personalize the appearance of Notepad++?
Ans.(d) Notepad++ is a free source code editor that
(a) style (b) edit Menu
supports multiple languages. Notepad++ supports
syntax highlighting and syntax folding. It supports (c) style configurator (d) file
regular expressions and auto complete, including word Ans.(c) While using Notepad++, if the user wants to
completion, function completion, and function personalize the appearance, then apart from the
parameter completion. preferences, they can use the style configurator
19. Which option in Notepad allows you to search for available just below the Settings button.
any text and then replace it with new text?
(a) edit (b) format 25. To insert a function from the function list…
(c) go-to (d) Find and replace shortcut is used.
Ans. (d) The Find and replace option available in the (a) Alt + Space (b) Shift+Space
Edit menu of Notepad allows finding every instance of (c) Ctrl + Space (d) Ctrl + Shift + Space
a certain text in the entire document and replacing
Ans. (c) Function can be inserted from the function
each instance with a new text.
list by using Ctrl + Space shortcut key. This feature
20. The option used to save the Notepad window is–
(a) edit (b) apple displays to the user all the functions built into a
(c) format (d) Save As program.
M2R5 23 YCT
3 HTML BASICS
M2R5 24 YCT
</BODY> • Top Margin– This sets the top margin of the
˙˙˙ document.
˙˙˙ • Link – Sets the text color of an unvisited hyperlink.
• VLink – Determines the text color of the visited
</BODY>
hyperlink.
Body Tag is the main Tag and our actual coding • ALink – Sets the selected hyperlink text color.
starts from here. There are some characteristics of a web • <h1>– It is the heading tag of HTML page. You can
page which the attributes of the <body> tag are specified use <h1> to <h6> tags to give heading.
as – Background, BGCOLOR, Text, LINK, ALINK and • <p>– This is Paragraph tag, you can use it to write
VLINK and left margin upper margin. Paragraph in HTML web page.
♦ Bg Color 3.2 Head Section & It's Elements:
We use this property to give color to the background
The <head> tag is a container tag that is placed
in the body. To use it, we first need to add bg in the body inside the <html> element and before the <body> tag. the
tag. After writing color, the name of the color has to be data written in this container which is not shown to the
written in double quotes ("") followed by equal sign (=). user is known as metadata. Title character set in
Syntax: metadata, Styles, links, scripts and other meta
<body attribute = "values"> information are stored. For this we use itle> <style>,
<body> <meta>, <link>, <script> and use elements like base>.
for example HTML <title> Element– It is used to give title to
<body bg color = "red"> an HTML document. This is displayed on the user's
browser. It is used to provide the title of that page when
......
the user saves the page or adds it to favorites. This title is
...... displayed as a result in search engines so that users can
...... know the gist of the document.
</body> Example:
<html>
By writing like this, the color of the body will be <head>
change. We can either give the color name in the value <title> Youth Competition Times </title>
or can also give the hexacode. </head>
♦ Back ground <body>
It is used when we have to put an image in the ˙˙˙
background of the body, this is also written on the bg </body>
color side. But in this we have to enter the path or Ui of </html>
the image instead of color.
for example,
<body background = "sample - image ⋅ jpg">
...... HTML <style> Element– Using this, CSS of any
...... page can be set. This element can be used anywhere but
...... according to coding standards it should be placed inside
the <head> element only. The <style> tag provides style
<body> for HTML tags.
♦ Text Example:
The text attribute is used to change the color of the <!DOCTYPE html>
text written inside the body. In this, the color code has to <html>
be given in the value. If we enter color name in text then <head>
we will see text of the same color.
<title> HTML document </title>
for example,
<style>
<body bg color = "blue" text = "white">
body{background-color : Yellow}
...... P{background-color : skyblue}
...... </style>
...... </head>
<body> <body>
Similarly, <p> Paragraph Tag </p>
• Left Margin– This sets the left margin of the web </body>
document. </html>
M2R5 25 YCT
Output:
HTML <meta> Element– It is used to specify HTML <Script> Element– In this tag, JavaScript
character set, page description, author name and similar code is given on the HTML document and external-js file
meta information used in HTML document. is also given on the HTML document with 'src' attribute.
Metadata is used by the browser and all the details This element is used to define client side scripts. The
of how to display the HTML document through the syntax is written with <script> </script>, with the script
HTML browser are given in the metadata itself. inserted between the beginning and end tags.
Example: <!DOCTYPE ⋅ html>
To define character set, <html>
<meta <head>
char set="UTF – 8"> <title> HTML Document </title>
To HTML Page description define, <script type = "text/javascript">
<meta bocument⋅write ("Hello World"):
name = "description" </script>
content = "free HTML </head>
tutorials Hindi"> <body>
To define keywords in search engines, </body>
<meta </html>
name = "key words" HTML <base> Element– The <base> tag specifies
content = "HTML, CSS, XML, Javascript, the base URL for all URLs in HTML document. After
Tutorial, Hindi"> this the user does not need to write the complete URL.
To define author, Whenever users add a URL, the Base URL is
<meta automatically prefixed before that URL.
name = "author"
Example:
content = "John Doe"> <html>
To automatically refresh the page every 30 seconds, <head>
<meta http – <title> HTML base tag Demo </title>
equiv = "refresh" <base href = "c:/documents/web-files">
content = "30"> </head>
HTML <link> Element– This tag is used to load an <body>
external link sheet into an HTML document, but it can
also be used by search engines to provide links to related <img src = "my Image ⋅ Png">
resources on a website's navigational structure. </body>
</html>
Mystyle ⋅ CSS
hl {background - Color : red}
h2 {background - Color : Blue}
h3 {background - Color : Yellow}
h4 {background - Color : Purple}
Sample ⋅ html
<!DOCTYPE html> 3.3 Writing a program using HTML in
<html> Notepad:
<head> Notepad text editor is generally used to write HTML
<title>HTML Document </title> programs. To create a webpage on Notepad, follow the
<link rel = "Stylesheet" href = "mystyle ⋅ css"/> following steps–
</head>
<body> Step-1: Click on Start button. Select All Programs.
<h1> Header </h1>
<h2> Header </h2> Step 2: Write HTML code on Notepad–
<h3> Header </h3>
<h4> Header </h4> <!DOCTYPE html>
</body> <html>
</html> <body>
M2R5 26 YCT
<h1> My First Heading </h1> 3.3(i) What is Element:
<p> My First Paragraph </p> The combination of HTML tag and content is called
</body> HTML element. It is called a start HTML element. A
</html> start HTML tag, an end HTML tag and the content
between them are collectively called an HTML element.
HTML elements are made up of HTML tags. An element
has no separate existence. Every part of a web page such
as a paragraph, image link etc. is an element. Each type
of element has its own behavior. For example, you can
click on a link or type in a text box.
M2R5 32 YCT
3.4(xx) Links-Colors & Download link: Creating Image Links– Images can also be
You can set the colors of your links, active links, converted into links. <a> tag is used for this. This makes
and visited links by using the link, alink, and vlink the image clickable and on clicking the image another
attributes of the <body> tag. URL opens there.
Hovering over a link; Example:
• The mouse arrow will change to the shape of a small <!DOCTYPE html>
hand. <html>
<head>
• The color of the link element changes. <title> Image Hyperlink </title>
By default the link looks like this in all browsers;
</head>
• An unvisited link will be underlined and blue. <body>
• A visited link will be underlined and purple. <p> click following Image Hyperlink </p>
• An active link will be underlined and red. <a herf = "http://www.yct.com" target = _self">
There are four types of HTML links like– <img src = "yct⋅Png" alt = "Image Hyperlink" border
Internal link– In internal link, another URL of a = "0"/>
website is given by clicking on which you can go to </a>
another page of the same website.
External link– By clicking on the external link, we </body>
come to the page of another website. </html>
Download link– This link is used to make different Output:
files downloadable. Therefore, you will have to add the
download attribute in it.
E-mail link– You can also give the link by creating
an e-mail link, hence the e-mail address has to be written
in the href attribute. Like–
<a href = "[email protected]"mail us </a>
M2R5 33 YCT
Output:
• <SVG>: HTML 5 supports scalable vector graphics • <nav>: Whenever you view a website, you see a menu
(SVG). This feature is a very special feature. Any which contains page links. Website menus are defined
graphic can be easily draw through SVG. <SVG> is inside the <nav> element in HTML 5.
known as an element. <!DOCTYPE html>
<!DOCTYPE html> <html>
<html> <body>
<body> <h1> The nav element </1h1>
<svg width = "100" height = "100"> <p>The nav element defines a set of navigation
<circle cx "50" cy = "50" r = "40" link:</p>
<nav>
stroke = "green" stroke⋅width = "4" <a href = "/html"/> HTML </a>/
fill = "yellow"/> <a href = "/CSS/">CSS</a>
sorry, your browser does not support inline SVG. <a href = "/js/"> Javascript</a=/
</svg> <a href="/python/"> Python </a>
</body> </body>
</html> </html>
M2R5 44 YCT
Output: <h2> Microsoft Edge </h2>
<p>Microsoft Edge is a web browser developed by
Microsoft, released in 2015. microsoft Edge
replaced internet.
Explorer. </p>
</article>
</body>
<html>
Output:
• <section>: Any number of sections can be created in a
website. Section works like a blog in which it works
like a complete blog and HTML code is defined for a
complete block. The advantage of section is that we
can define the HTML code for the block. The
advantage of the section is that we can easily
understand and read that block code.
<!DOCTYPE html>
<html>
<head>
<title> using the section tag </title>
</head>
<body> • <aside>-<aside>: element is a good structure feature
<section> of HTML 5 in which we define the sidebar. Whatever
<h2> Hypertext markup language HTML </h2> the code of the sidebar is. All that is written in <aside
<p>HTML is the standard markup langage for > element. This feature of HTML5 is being used a lot.
rating web pages and web applications browsers <!DOCTYPE html>
receive HTML documents from a web server or <html>
from local storage and render the documents into <body>
multimedia web pages </p> <h1> The aside element </h1>
</section> <p> my family and I visited The Epcot center this
<section> summer⋅</p>
<h2>CSS </h2> </aside>
<p>formal language, which is used as a description <h4> Epcot center </h4>
</section> <p> Epcot is a theme park at walt Disney world
</body> Resort featuring exciting attraction international
</html> pavillions </p>
Output: </aside>
</body>
</html>
Output:
Time– Time input type is used to get time from the 3.13 HTML 5 Embed Tag:
user. The inputted time has no time zone. If the browser If you want to add any multimedia file in your
webpage like Audio, Video or Flash etc., then <embed>
supports this input type then it becomes Time Picker. tag is used for this. Using this tag, you can easily add any
Example: multimedia file to the webpage.
<html> The <embed> tag creates a panel inside the webpage
<head> that displays your multimedia files. When <embed> tag
<title> Time Input Type Demo </title> is used, its controls are automatically provided by the
browser in the panel. For example, if a video is added,
</head> then controls like Play, Pause etc. are automatically
<body> provided by the browser.
<h2> What time did you woke up today? </h2> There are 4 required attributes used with the HTML
<form> <embed> tag. Which are as follows–
• Src: Through this attribute you give the address of the
<input type = "time" name = "WK Time"> file that you want to include in the webpage.
<br> <br> • Height: This attribute defines the height of the created
<input type = "Submit"> panel.
</form> • Width: This attribute defines the width of the created
</body> panel.
• Type: With this attribute you can define the type of
</html> the included file.
Output: Example:
<html>
<head>
<title> Embed Tag Example </title>
</head>
<body>
<h2> my favorite movie </h1>
<embed src = "/media/video/myfile"
height = "300" width = "300">
</body>
</html>
Output:
M2R5 50 YCT
9. The attribute that defines the relationship 15. What is the correct HTML tag for smallest
between the current document and the HREF'ed heading size–
URL– (a) <h6> (b) <h1>
(a) REL (b) URL (c) <heading> (d) <header>
(c) REV (d) All of the above Ans. (a) To define the document structure properly in
Ans. (a) REL defines the relationship between the HTML language, 6 types of headings are given which
current linked document and the HREFed URL. REL are H1, H2, H3, H4, H5, H6 level headings. To create
is the short form of Relation and the full form of href the smallest size heading, 6th level heading is used, it
is Hypertext Reference. This is the source file used by is also helpful in dividing the content deeply. This is
the tag. You can use both of these when connecting the heading of least importance. It is defined by H6
external CSS files as well as when using the <> tag for element and <h6> tag.
hyperlinks.
16. <a> Tag is used in HTML for–
10. Apart from <b> tag, which HTML tag makes the
(a) list (b) Links
text bold–
(d) none of these (c) address
(a) <blank'> (b) <strong>
(c) <bold> (d) none of these Ans. (b) In HTML, <a> represents an anchor tag and a
link is defined from the opening anchor tag and </a>
Ans. (b) Bold element is used to define bold text in
tag is used to close it.
HTML. This makes the text darker and thicker than
the text next to it. In addition to the <strong> tag in 17. Which tag inserts horizontal lines in your web
HTML, the <Strong> tag can also be used to bold text. page.
11. Bulleted list can be created using which of the (a) <hr> (b) <line>
following tags? (c) <line direction = "horizontal">
(a) <dl> (b) <nl> (d) <tr>
(c) <ul> (d) <ol> Ans. (a) The full name of <hr> element is Horizontal
Ans.(c) UL stands for unordered list of elements. A Line. The hr element defines a horizontal line in an
bulleted or unordered list is created by the Unordered HTML document.
List element. 18. The <DT> tag is designed to contain a single line
12. Which of the following is not a screen frame in of our web page but the <DD> tag will accept a --
HTML? --------.
(a) iframe (b) noframe (a) line of text
(c) frameset (d) uframe (b) Complete paragraph
Ans. (d) HTML frames are used to divide the browser (c) word
window into multiple sections where each section can (d) request
load a separate HTML document. A collection of Ans. (b) The full name of the <dt> element is
frames in a browser window is known as a frameset.
Definition Term and through it the definition list is
iframe, noframe, framset screen frame in html.
defined that accepts a single line and the full name of
13. What is the correct HTML to create a hyperlink?
the <dd> element is Definition Description, through it
(a) https://yctonline.com</a>
the description of the definition term is defined and
(b) <a href="http://yctonline.com">Book
(c) url = https://yctonline.com>Book store</a> can accept complete paragraphs.
(d) <a name = "https://yctonline.com> Book store 19. What is required to create HTML document–
Ans.(c) The correct HTML code to create a hyperlink (a) Webpage editing software
is– (b) High power computer
<a href = "http://yctonline.com">Book Store </a> (c) Can use only notepad.
14. What is meant by Vlink attribute in the (d) None of these
following? Ans. (c) To create an HTML document, first of all it is
(a) Viewed links (b) Virtual link
necessary to have a simple text editor. Notepad is used
(c) very good link (d) Active link
for this.
Ans. (a) Full form of Vlink attribute is Visited Link.
This refers to previously viewed links. The link which 20. The correct HTML tag for the largest heading is–
has been clicked by the user. Its color is purple and it (a) <head> (b) <h6>
is also underlined. (c) <heading> (d) <h1>
M2R5 51 YCT
Ans. (d) Headings are defined in an HTML document Ans. (c) The full name of <DL> element is Definition
through the heading element. Heading can be created List. The definition list is defined by the definition list
in HTML from H1 to H6 level. The <H1> tag is used element.
for the largest heading. This is the main part of the 25. The tag used for superscript in HTML is–
HTML document. There is a heading and it is also the (a) <Super> (b) <Spr>
most important. The title of a blog post or webpage is (c) <Sup> (d) <up>
defined by the H1 level heading. It is recommended to Ans.(c) <Sup> tag is used to superscript text in
use this heading only once in the document. HTML. Full name of <Sup> element is Superscript.
21. The special formatting code in HTML document 26. HTML used tag for line breaks–
used to present content is– (a) <B> (b) <br>
(a) Tags (b) Attributes (c) <break> (d) <Line>
(c) Values (d) none of these Ans. (b) The full name of <Br> element is break. It is
Ans.(a) The special formatting codes used in HTML used to give single line break.
documents to present content are called tags. Whereas 27. To write headings in HTML ............ Heading tags
HTML attributes are used to define the characteristics are available.
of HTML tags and all HTML tags are displayed in (a) 4 (b) 5
their default values. Attributes are used only to change (d) 3 (c) 6
this default value. Ans. (c) Heading is a word, syllable or sentence.
22. What is the correct HTML code to add color to Which is written first in any document, article, blog
the background? post etc. Heading is similar to page title. To write
(a) <body bgeolor = "Blue"> headings in HTML, we have 6 heading tags (H1, H2,
(b) <body background = "Blue"> H3, H4, H5 and H6). HTML headings are used based
(c) <body color = "Blue"> on their importance. <h1> level heading is used for the
(d) <background > Blue < /background> most important heading and <h6> level heading is
used for the least important heading.
Ans.(a) To add background color to an HTML
document, the HTML code should be as follows– 28. ......... feature is used to combine cells vertically.
<html> (a) Rowspan (b) Colspan
(c) Table (d) Merge
<head>
Ans. (a) Rowspan is an attribute of <table> tag.
<title>youth competition times.com</title>
Rowspan attribute merges two or more rows into one
</head>
row.
<body bgcolor = "Blue">
29. The main container for <TR><TD> and <TH>
</body>
is–
</html> (a) <table> (b) <base>
When the above code is run, the document (c) <main> (d) <section >
background will be displayed in blue color. Ans. (a) The main container for <TR><TD> and
23. HTML is– <TH> is <table>. The full name of <TR> element is
(a) Hypertext Markup Language Table Row. Through this the table row is defined. The
(b) Hypertext Markup Language full name of <TD> element is Table Data, through
(c) Hypertext Marked Language which table data is defined and the full name of <TH>
is Table Header, through which table header i.e. cells
(d) Hyper Text Marking Language
are defined.
Ans. (b) Full form of HTML is Hypertext Markup
30. How to create order list in HTML–
Language. It is a markup language. Which was (a) <ul> (b) <ol>
developed in the 90s to create web documents (web (c) <href> (d) <b>
pages). It is the base of a web page and web pages are Ans. (b) Order list is defined by <ol> tag and list item
the basis of a website. HTML uses tag to create web is defined by <li> element. In the order list, they are
documents. also called number list because the list items are
24. The tag used for definition list in HTML is– written in order of number before them. This type of
(a) <OL> (b) <Dt> list is used to display same type of information in a
(c) <DL> (d) <Unorder> fixed order.
M2R5 52 YCT
4 CASCADING STYLE SHEET
4.1 Introduction of CSS: same style to any HTML elements then you can
CSS (Cascading Style Sheet) is used to design a easily style them together in one file, thus it reduces
website. This is used by web designers and the HTML code and loads the web page faster.
programmers. It works to make attractive to any (iv) The same style sheet can be used on multiple web
elements in the web page. CSS is coding. It was pages so if the user ever wants to change the design
developed by the World Wide Web (www) Consortium of all their web pages then just a few code lines have
in 1996 for website designing. It is always used with to be updated in the same file and then the entire
HTML. The use of HTML gives a shape to the webpage website is designed automatically. It will be
and the use of CSS gives a new and attractive look to the updated.
web page. (v) CSS can also allow an HTML document to be
The latest version of CSS is CSS3. CSS is a way to optimized for more than one type of device or
turn a web page into a dynamic webpage. It can be used media. Using CSS you can create a good responsive
with any type of XML document, including SVG and design which can render your website in different
XUL. From Web to multiple mobile apps CSS is used styles for different types of devices like mobile,
along with HTML and JavaScript in most websites for tablet, laptop, desktop, printer etc.
applications and user interfaces. 4.1(ii) Advantages of CSS:
Like HTML and other computer languages, CSS By using CSS we can display the text of the
rules also have a syntax for writing. Through which CSS webpage in good color. You can control the styles of
declaration is written for HTML document. CSS syntax fonts and the space between paragraphs. CSS, adds style
is also called style rule. It has mainly two parts– to your web pages by interacting with HTML elements.
With CSS you can create a responsive website. Like
HTML, we also need a text editor (like Notepad or
Notepad++) to write CSS.
Following are the benefits of CSS–
• CSS provides a lot of flexibility for setting properties.
Once you write CSS, you can apply the same code to
multiple groups of HTML elements. We can say that
by using CSS we can save our time.
Selector– A selector is a word group/letter for which • It reduces page load time because designing pages
the style rule is written, it is written as a bracket. This is with CSS requires very little code. Less code in a web
usually an HTML tag but it can be written with any page means it will load faster.
name. • It is quite easy to maintain a document through CSS.
Declaration– This is the part of the style rule in With just one change in CSS, you can instantly update
which the style for a selector is declared. This also has multiple pages in that document.
two parts– • Using CSS, the same web page can be given
• Property: This is the part of the style rule that shows compatibility across multiple devices. So that the web
the style we want to apply to a selector. This is written page can be viewed on all devices, computers, the
within the curly bracket. This is called an attribute of phone can be viewed according to them.
the HTML tag. • Traffic comes to a website only when the pages of that
• Value: The third part of the style rule is value. This is website rank first in a search engine. With the use of
also written inside curly brackets. Set value for CSS, it becomes easier for the search engine to access
property in this. that website, due to which it can quickly access and
4.1(i) Features of CSS: rank that page.
Some important features of CSS are as follows– 4.2 Types of CSS:
(i) Web pages can be made beautiful and attractive by There are three types of HTML pages–
using animation and transitions in CSS. (i) Inline CSS (ii) Internal CSS (iii) External CSS
(ii) A lot of time can be saved by using CSS. Viewing HTML web page is designed using the CSS of that
every page even, if a website has a maximum structure. Using CSS in HTML there are three types.
number of pages each page is similar in appearance (i) Inline CSS– Inline CSS is the way of using CSS
and design. The same CSS file can be used on in one line as the name suggests- (Inline) in one line.
multiple HTML pages. When you need to use CSS within a single HTML
(iii) Using CSS there is no need to add attributes to each line or paragraph you can use CSS within a DIV or with
tag to style HTML elements. If you want to give the an HTML tag.
M2R5 53 YCT
Example: <p> This is a paragraph. This is a paragraph. This is
<!DOCTYPE html> a paragraph. This is a paragraph. This is a
<html> paragraph. </p>
<head> </div>
<title>Inline CSS in HTML </title> </body>
</head> </html>
<div> Output:
<style> = "height : 100PX ; width : 400PX;
background - color : grey ; color : white ;">
</style>
<h1> welcome to our website <h1>
<P Style = "color:red;"> This is a paragraph.
This is a paragraph. This is a paragraph. This is a
paragraph. </p>
</div>
</body> (iii) External CSS– This is the third type of CSS in
</html> which a separate file is created for CSS and that file is
Output: linked to the HTML page. All the CSS code is written in
the CSS file. This one is the best and the most used
method.
To create external CSS, style it by writing CSS code
in a new file of Notepad and save the CSS like this and
Linked in HTML. You can name the CSS file anything
but the extension of CSS along with the name of the file,
the file is saved after writing.
Example–
style.CSS
header.CSS
footer CSS etc.
To create a CSS file and link it in HTML, link it like
(ii) Internal CSS– Internal CSS means creating and this with the help of HTML link tag.
using CSS on an HTML page, which means we <link rel = "style sheet" type = "text/CSS"
create a CSS inside the HTML <head> tag and use it href = "my file.CSS">
by calling the class and ID. Internal CSS means Create the CSS file like this.
when we create CSS in html head tag and use it in my file.html
the same page, such CSS is called internal CSS. It is <!DOCTYPE html>
very simple to create and use an html page. Intemal <html>
CSS is used in HTML by creating <style> </style> <head>
in the head tag of HTML. Creating and using CSS in <title> Internal CSS in HTML </title>
the same HTML page is called internal CSS. Inline <ink rel = "sylesheet" type="text/CSS" hert =
CSS is used in code with only one line or one tag. "myfile. CSS">
HTML is created inside the head tag. Which can be </head>
used anywhere on the entire page, <div class= "header">
Example: <h1> Welcome to our webite <h1>
<!DOCTYPE html> <p> This is a paragraph.This is a paragraph.
<html> </p>
<head> </div>
<title>internal CSS in HTML</title> </body>
<style> </html>
header { Output:
height : 100PX ;
Widh : 400PX ;
background-color : grey ; color : white ;
}
p{
Color : red ;
}
</style> In the above example, we have created an HTML
</head> page and used the html link tag to link the CSS file.
When you link a CSS file to an HTML page, the effect of
<div class = "header">
CSS is seen on the HTML page. In this way, the effect of
<h1> Welcome to our website </h1> CSS can be seen in HTML by using the CSS type.
M2R5 54 YCT
4.3 CSS Selectors: • ID Selector: ID Selector selects elements on the basis
The CSS selector selects the content for which we of ID defined in HTML elements. #id name (hash) is
want to write CSS rules. CSS rules of Selectors' are a used to select elements defined with ID.
part of syntax, which can be an HTML element attribute. Example:
CSS selectors select HTML elements according to their <!DOCTYPE html>
ID, class, type, attribute, etc. Thus the selected elements <html>
can be styled as per the requirement of the users. <head>
CSS selectors can be divided in five categories as <meta charset = "utf-8">
follows– <title> CSS ID Selector </title>
(i) Simple Selectors: In this, elements are selected <style>
on the basis of id, class and name. /*Select according to ID*/
(ii) Attribute Selectors: In this, selection is on the #myheading {color: red;}
basis of attribute and attribute value. </style>
(iii) Pseudo-elements Selectors: It is used to style a <body
part of the elements by selecting them. <h2 id = "my heading">CSS ID Selector </h2>
(iv) Combinator Selectors: Elements are selected </body>
on the basis of a specific relationship between the </html>
elements. Output:
(v) Pseudo-Class Selectors: It is used to select
elements based on a certain condition.
Some important selectors in CSS are as follows–
• Element/Tag Selector
• ID Selector • CSS Class Selector: It selects elements on the basis of
• Class Selector the class defined in the details. Class (dot) is used to
• Universal Selctors select the element defined with class.
• Group Selector Example:
• Attribute Selector <!DOCTYPE html>
• Element/Tag Selector: In this Type of Selectors, we <html>
apply style by selecting the HTML element directly <head>
from its name. <meta charset = "utf-8">
Example: <title>CSS Class Selector </title>
<!DOCTYPE html> <Style>
/*Select according to class*/
<html>
my class {color: red :)
<head> </style>
<meta charset = "utf-8"> </head>
<title>CSS Element/Tag Selector</title> <body>
<style> <h2 class = "my class"> CSS class selector </h2>
/*change page background color : black*/ </body>
body{background-color : black ;} </html>
/*all h3 headings color : red*/ Output:
h2{color : red ;}
</style>
</head>
<body>
<h2>CSS Element Tag Selector</h2>
</body> • CSS Universal Selector: All the elements present in
</html> the webpage are selected through universal selector.
Output: Example:
<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<title>CSS Universal Selector </title>
<Style>
/*select all element*/
*{Color: Blue; font-weight: bolder;}
</style>
</head>
<body>
M2R5 55 YCT
<h2>Heading Tag</h2> webpage for which target attribute has been defined and
<p> paragraph </p> value_blank of that attribute has been defined, then you
<div> Div </div> cannot do this through normal selectors. But it is very
<span> span </span> easy to do this through attribute selectors.
</body> Example:
</html>
<!DOCTYPE html>
Output:
<html>
<head>
<meta charset = "utf-8">
<title>CSS attribute Selector </title>
<style>
body {background-color:Pink;}
h2 [test-'attribute'] {color : red ;}
CSS Group Selector: When we want to apply the </style>
same style on an element we can select multiple elements </head>
together by using tag, ID or class.
Don't use it for same style <body>
#my ID {color: blue; font-weight: bolder ;} <h2 test = 'attribute'> Test Attribute </h2>
my class {color: blue; font-weight: bolder;} </body>
Span (color: blue; font-weight bolder;} </html>
Instead you should use this.
#my ID, my class, span {color: blue; font-weight: Output:
bolder ;}
To select more than one element simultaneously,
select the elements by separating the selectors with
Comma (,).
<!DOCTYPE html>
<html> CSS [attribute] Selector: This selector targets
<head> elements that have an attribute defined in angular
<meta charset="utf-8"> brackets. The general syntax of this selector is as
<title>CSS Group Selector </title> follows–
<Style> [attribute-name]
/*Select needed elements at once*/
#my ID, my class, span (color: blue, font: weight: {
bolder :) property: value;
</style> }
</head> You can see in the above syntax that should be
<body> match with defined attribute in angular brackets.
<h2 id="my ID"> My Heading </h2> Example:
<p class ="my class"> my paragraph</p>
<html>
<span> Normal paragraph </span>
</body> <head>
</html> <style>
Output: [target]
{
bacground-color : yellow ;
}
</style>
</head>
<body>
<a href = "http://www.yct.com "target"=_blank">
CSS Attribute Selectors: CSS provides the ability
Best Hindi Tutorials </a>
to design elements according to user attribute values.
That is, any element can be targeted in which a specific <a href "http://www.google.com in"> Google india
attribute or attribute values have been defined. For this </a>
there are many attribute selectors available in CSS. For </body>
example, if you want to target all those anchor tags of a </html>
M2R5 56 YCT
Output: <style>
[class∼ = "Animal"]
{
width: 50px;
height: 50px
background-color: blue;
}
CSS [attribute = "value"] Selector: This Selector [class ∼ = "Flowers"]
targets the elements specified in angular brackets. The {
attribute and its same value are defined. In this selector, width: 100px;
the value of the attribute is also defined by the height: 100px;
assignment operator before its name. While defining this background ∼ color: red;
selector, the value of the attribute is defined in double </style>
quotes. The general syntax of this selector is as follows– </head>
[attribute-name="value"] <body>
{ <div class = "Animal Div"> </div>
Property value; <div class = "Flowers Div"> </div>
} </body>
This selector affects only those elements whose </html>
attribute and the one defined for it have an exact match. CSS [attribute | = "value"] Selector: This selector
Example: targets elements in which the value of the attribute
<html> specified in angular brackets starts with the specified
<head> word. In this selector, after the name of the attribute, the
<style> vertical (|) line symbol is written in double quotes which
[class = "p1"] you want to match with the value of the attribute.
{ After that it is important to keep in mind that the
bacground-color: yellow ; word should be complete. If hypen has been used before
} the word while defining the attribute, then while defining
</style> the word, hypen should be used in front of it also. If you
</head> do not write a complete word then no element will be
<body> targeted.
<p class="p1"> This paragraph will be effected.</a> For example, if you want to select a Paragraph
<p> This paragraph will not be effected.</p> element whose Class attribute's starts with first value,
</body> then you can do so through this selector. The general
</html> syntax of this selector is as follows–
Output: [attribute-name | = "Containing-word"]
{
property : value;
}
Example:
<html>
<head>
CSS [attribute ~ = "value"] Selector: This selector <style>
targets elements that include the specified word in the [class = "First"]
value of the attribute. While defining this selector, a tilde {
(∼) symbol is defined after the name of the attribute. And Color: blue;
after that by applying assignment operator it is specified }
in double quotes which can be included in the value of </stlyle>
any element. </head>
For example, you want to target some div in which <body>
the class attribute is defined and the value of that <p class = "First-paragraph"> This is first
attribute includes the words animal and flowers, then in paragraph. </p>
such a situation you can use this selector. </body>
The general syntax of this selector is as follows– </html>
[attribute-name = "containing-word"]
{ CSS [attribute^ = "value"] Selector: This selector
Property: value; also targets elements whose specified attribute value
} starts with the specified word. The only difference is that
Example: in this selector you do not need to define the word
<html> completely. As if some letters are also defined then this
<head> selector targets the elements.
M2R5 57 YCT
While defining this selector, circumflex (^) accent Output:
symbol is defined after the name of the attribute and after
that, by applying assignment operator, the word is
written in double quotes which you want to match with
the value of the attribute.
The general syntax of this selector is as follows–
[attribute-name∧ = "containing-word"]
Property: value; CSS [attribute*= "value"] Selector: This selector
} also targets elements whose specified attribute value
Example: contains the specified word. This selector is similar to
<html> the [attribute = "value"] selector, the only difference is
<head> that you do not need to specify the entire value exactly.
<style> You can define only some letters which will match the
[class^= "ed"] value of the element's attribute and that element will
{
become the target.
back ground : yellow ;
} While defining this selector, asterisk (*) symbol is
</style> defined after the name of the attribute and after that by
</head> applying assignment (=) operator, the word which you
<body> want to match is specified in double quotes.
<p class ="red-paragraph">This is red paragraph The general syntax of this selector is as follows–
</p> [attribute-name* = "containing - word"]
<p class ="green-paragraph">This is green {
paragraph.</p> Property: name:
</body> }
</html> Example:
Output:
<html>
<head>
<style>
[class * = "rst"]
{
background-color : gold ;
CSS [attribute $ = "value"] Selector: This }
Selector targets elements whose specified attribute
values end with the specified word. While defining this </style>
selector, doller ($) symbol is defined after the name of </head>
the attribute and after that the word is defined in double <body>
quotes by applying assignment (=) operator. Which you <p class = "first-paragraph"> This is first Paragraph.
want to match with the value of the attribute. It is not </p>
necessary that the Word should be complete.
The general syntax of this selector is as follows. <p class = "second-paragraph">This is second
[attribute-name $ = "value"] paragraph</p>
{ </body>
property: value; </html>
}
Example: Output:
<html>
<head>
<style>
[class $ = "graph"]
{
back ground-color:green;
}
</style> Sub Selector– A CSS selector can contain more
</head>
<body> than one simple selector. There are four different
<span class = "first-span"> This is first span combinations in CSS. If you want to apply CSS on top of
</span> <br/> an element, then the sub element selector is used when it
<p class = "first-paragraph"> This is first Paragraph has to be applied to the sub elements of that element.
</p> First of all, the name of the main element is defined in
<span class "=second-span"> This is second span the body of the <style> tag, after that, by giving space,
</span> </br> write the name of the sub-element on which you want to
</body>
</html> apply.
M2R5 58 YCT
Example: Output:
<html>
<head>
<title> sub-element selector </title>
<style>
h1 span {
Color : blue ;
}
</style>
</head>
<body> The above example will apply, p+p means that the
<h2>element<span>selector</span>apply tags</h2> style rule on the second and third <p> elements
immediately after the first <p> element
</body>
(iii) Child Selector– It is similar to Descendant
</html> Selector but if you want to apply CSS rule on the child of
Different selectors allow the user to perform any element, then Child Selector is used. In this, Greater
different functions. These are four different combinators than Symbol (>) is put after Parents Selector and then
in CSS as follows– Child Selector is written.
Example:
(i) Descendant Selector– When there is another <html>
element inside one element then, to apply style rule on <head>
the inner element we use Descendant Selector. <style>
Example: div>b{
<html> Color: red;
<head> }
<style> </style>
pb{ </head>
Color: red; <body>
} <div>
</style> <b> This is first paragraph </b>
</head> <p> This is <b> second paragraph.</b> </p>
<body> </div>
</body>
<p> we are learning <b> CSS
</html>
tutorial in Hindi By yct </b> </p>
Output:
</body>
</html>
Output:
M2R5 74 YCT
Practice Questions with Explanatory Solutions
1. The full form of CSS is– Ans.(c) not ( ) selector is used to find the elements
(a) Cascade Style Sheet that do not match the given element. The not (S)
(b) Cascading short sheet selector selects only those elements that do not match
(c) Cascading Style Sheets the selector S.
(d) None of these 8. Which attribute can be added to HTML/XHTML
Ans. (c) The full form of CSS is Cascading Style elements to identify them as members of a
Sheets. It is a style sheet language that is used to make specific group?
documents beautiful and attractive, written in markup (a) ID (b) div
language which includes elements like layout, color (c) Class (d) Span
and font. Ans.(c) Class is a global attribute which can be used
2. A CSS rule set contains– for CSS selector. The class is defined by the class
(a) Selector (b) Declaration block attribute on all elements to which you want to apply a
(c) Both (a) and (b) (d) none of these style. The class attribute can be associated with
Ans. (c) Full name of XML is Extensible Markup HTML/XHTML elements.
Language. It is a dynamic markup language. It is used 9. What should be the width of the table, so that the
to convert data from one form to another. CSS can be width of the table adjusts to the current width of
used to display the content of an XML document
clearly and accurately. It gives design and style to the the browser window?
entire XML document. (a) 640 pixels (b) 100%
3. Extension of CSS file is– (c) fullscreen (d) 1024PX
(a) ⋅CS (b) ⋅CSS Ans. (b) When the table width is 100%, the table
(c) ⋅CSSX (d) ⋅CX width adjusts to the current width of the browser
window.
Ans. (b) While saving a new file, it is necessary to
pay attention to the file extension. The extension of 10. Which element is used in the <Head> section on
CSS file is ⋅CSS. an HTML/XHTML page if you want to use an
external style sheet to decorate the page?
4. What is true about XML? (a) <src> (b) <link>
(a) Extensible Markup Language (c) style (d) <ess>
(b) Markup language
(c) Gives design and style to the document. Ans. (c) A web page can be decorated with an
(d) None of these external style sheet using the <link> element under the
HTML/XHTML page <head> section.
Ans. (b) Full name of XML is Extensible Mark
Language. It is a dynamic markup language. It is used 11. Which of the following selectors selects any tag
to convert data from one form to another. CSS can be with the ID attribute set–
used to display the content of an XML document (a) E#id (b) Class
clearly and accurately. It gives design and style to the (c) #id (d) None of these
entire XML document. Ans.(c) #id selector selects any tag with id attribute
5. What can be used as wild card character– set. The id selector selects the id attribute of an HTML
(a) Element selector (b) Universal selector element to select a specific element. ID is always
(c) Both (a) and (b) (d) None of these unique within the page therefore it is chosen to select
a single unique element.
Ans.(b) Universal selector is used to apply the same
style rule to all the elements available in an HTML 12. Character coding is–
document. The universal selector is represented by (a) Method used to represent numbers in a
*(Asterisk). It can be used as a wild card character. If character
you declare a separate CSS rule for an element, the (b) The method used to represent a character in a
universal selector has no effect on that particular number
element. (c) A system consisting of a code that pairs each
6. Which of the following selectors selects the character with a pattern, sequence of natural
element that is the first child of the parent? numbers, or electrical pulse to transmit data.
(a) :first-of-type (b) :last-child (d) none of these
(c) :first-line (d) :first-letter Ans.(c) Character coding is a system that consists of a
Ans.(a) Web masters get flexibility through the code that pairs each character with a pattern, sequence
different types of selectors available in CSS. The first- of natural numbers, or electrical pulse to transmit data.
That is, we can say that character encoding is the
of-type selector is used to style each first child of a system which tells the computer how to display binary
parent element according to the given type. codes in characters.
7. Which of the following selectors selects elements 13. Which property is used to change the
that do not match selector S ? background color in CSS.
(a) : (S) (b) nth Child (S) (a) bg Color (b) background
(c) not (S) (d) none of these (c) color (d) back color
M2R5 75 YCT
Ans. (b) Through Background Color, you can change Ans. (a) A border can be displayed around a cell
the background of the web page to a different color. without any content by using the empty cell attribute.
Normally the background of a web page is always Users can also remove cells without content using the
white. In CSS, the background color is defined with empty cell hide attribute.
background-Color. 20. Which of the following functions flips the color of
14. Which of the following CSS list properties is an element for use by filter property–
correct? (a) Image ( ) (b) flip ( )
(a) Set individual list item markers for the order (c) invert ( ) (d) contrast ( )
list. Ans.(c) The values of filter properties are called filter
(b) Set a separate list item marker for the unordered functions. When invert ( ) is used it changes the color
list. of an element. The invert (%) value is used to set the
(c) Set an image as a list item marker. invert setting of the image. Its default value is (0%)
(d) All of the above. and 100% value completely inverts the image.
Ans. (d) List is like a container. Through this you can 21. Used to select all elements with similar style
display information in the form of structure on the definitions.
web page. In this, set different list items for the order (a) Group selector (b) Grouping selector
list. Set separate list item markers for unordered lists (c) Universal selector (d) none of these
and can set an image as a list item marker. Ans. (b) Group selector is used to apply CSS on more
15. If we do not want to allow floating div on the left than one tag simultaneously. The grouping selector is
side of an element, which CSS property would used to select all elements with the same style
you use– definition. Grouping selector is used to reduce the
(a) Margin (b) clear code.
(c) float (d) padding 22. The way to use CSS in one line is–
Ans. (b) Clear property is used to clear left float, right (a) Inline CSS (b) Internal CSS
float or both. By default the element can float to the (c) External CSS (d) none of these
left or right side. The Left clear property is used to Ans.(a) When CSS is written inside an HTML tag, it
disallow padding div on the left side of an element. is called inline CSS. In this method, CSS properties
16. Which of the following color formats is a CSS are written inside the "style" attribute. Inline CSS is a
color that can be defined using the keyword RGB way of using CSS in one line. If you need to use CSS
followed by three numbers in parentheses within an HTML line or paragraph, you can use the
between 0 and 255 separated by commas– CSS with a DIV or a html tag.
(a) RGB color (b) RGBa color 23. Color can be declared using the color property
(c) HSL color (d) HSLa color ............ available in CSS.
Ans.(a) It is very important to have color in the (a) foreground (b) background
website because it makes the webpage look beautiful (c) Both (a) and (b) (d) none of these
and attractive. There are many types of color codes in Ans.(c) The color property available in CSS is used to
CSS like RGB color, RGBA color, HSL color, HSLA declare the color for both foreground and background.
color and HEX color. RGB means Red, Green, Blue Foreground color means the color setting of elements
and color is changed with the help of these three. The like font color, border color, outlines, text color etc.
intensity of these three colors ranges between 0-255. Through color property you can easily declare color
Define the RGB color format by using the keyword for any html element.
RGB, followed by three numbers between 0-255,
separated by commas. 24. Value can be given in text transform property–
(a) test-transform: Upper case
17. CSS is.............language–
(a) Structural (b) Presentational (b) text-transform: lower case
(c) Mark up (d) Behavioral (c) text-transform: capitalize
Ans. (b) The full form of CSS is Cascading Style (d) All of the above.
Sheets. It is a language for styling web documents Ans. (d) Through CSS text transformation property,
developed by W3C (World Wide Web Consortiun). Its you can convert the text given in HTML into
first version was published in 1996. CSS3 is the latest uppercase or lowercase. The text transfer property has
version. It is used along with HTML to decorate a three values- text-transform.uppercase, text- transform
webpage. CSS is a presentational language.
: lowercase and text-transformcapitalize. Text-
18. When we write <img src = "img.png">, what transform : capitalize is used to start a word with a
"img.png" indicates inside the double quote–
(a) element (b) attribute capital letter.
(c) value (d) operator 25. The default value in the position property is ........
Ans. (c) When user writes <img src="img.png">, (a) static (b) Relative
displays the value "img.png" written inside double (c) fixed (d) Absolute
quotes. And img src denotes an attribute. Ans. (a) Through the position property, users can
19. Which of the following properties can be used to design the layout as per their choice. Static, relative,
display a border around a cell without any fixed and absolute position properties are available in
content?
(a) Empty cell (b) Blank cell CSS. The default position in an HTML document is
(c) Non-content (d) any cell static.
M2R5 76 YCT
5 CSS FRAMEWORK
M2R5 80 YCT
5.4(iv) Panel as Cards: Output:
W3.CSS Card is used to create effects like greeting
cards. These are containers with shadow borders. To
create these cards W3-Card-x is used where x is the
number of pixels of the shaded border which can be 2, 4,
8 or 12.
Example:
<!DOCTYPE html> 5.4(vi) W3.CSS Opening & Closing Panels:
<html> Here you have a button whose On click event ID
<title> W3.CSS </title> opens a div with ID "Panel div". This button opens a
<meta name = "view port" panel.
content "width=device-width, initial-scale=1"> Example:
<link rel = "style sheet href = " https://www.W3. <!DOCTYPE html>
Schools.com/W3.CSS/4/W3.CSS"> <html>
<body> <title> W3.CSS </title>
<div class = "W3-container"> <meta name = "view port"
<h2> panels as cards </h2>
content = "width = device-width, initial-scale = 1">
<p> The W3-panel class can be used to display
cards:</p> <link rel = "style sheet href =" https://www.W3
<div class = "W3-Panel W3-blue W3-Card-u"> schools.com/W3⋅CSS/4/W3.CSS">
<p> London is the most populous city in the united <body>
kingdom, with a metropolitan area of over 9 <button> <class = "W3-button W3-red" on click =
million inhabitants.</p> "document.getElementByld('id01')⋅style
</div> display = 'block'"> show panel </button>
</div> <button> <class " = W3-button W3-red"
</body> on click = "document.get Element Byld ('id01') style
</html> display = 'block'">show panel
Output: </button>
<div id = "id01" class = "W3-panel W-green W3-
display-container" style = "display : none">
<span onclick = "this.parent Element.style.display =
"none">
class = "W3-button W3-red
W3-display-topright> x </span>
<p> click on the x to close this panel. </p>
5.4(v) W3.CSS Round Panels: <p> click on the x to close this panel. </p>
Creating a round panel is very simple, you need to </div>
add the class W3 Round Size, where you have to change </body>
the size⋅ You want the roundness to be displayed with the </html>
size. Output:
Example:
<!DOCTYPE html>
<html>
<title> W3.CSS </title>
<meta name = "view port"
Similarly, if you look at the panel div, there is
cntent = "width = device-width, initial-scale = 1"> element span tag with W3-close btn. This closes the
<link rel = "style sheet" href = "https://www.w3 panel.
schools.com/W3 CSS/u/W3.CSS"> Example:
<body> <!DOCTYPE html>
<div class = "W3-container"> <html>
<h2> Rounded panels </h2> <title> W3.CSS </title>
<div class = W3-panel W3-blue W3-round-xlarge"> <meta name = "view port"
<p>London is the most populous city in the united content = "Width = device-width, initial-scale = 1">
kingdom, <link rel = "style sheet" href = "https://www.W3
with a metro politan area of over 9 million schools.com/W3 CSS/u/W3.CSS">
inhabitants. </p> <body>
</div> <div class = "W3-container">
</div> <h2> Hidding panels </h2>
</body> <p> Hiding a panel can be done using an on click
</html> event on a W3-button:</p>
M2R5 81 YCT
</div> <div class = W3-panel W3-border">
<div class = "W3-panel W3-red W3-display- <p> I have borders.</p>
container"> </div>
<span on click = "this.parent Element.style display <div class = "W3-panel W3-border-right">
= 'none'">
<p> I have only a right border.</p> </div>
<class = "W3-button W3-red W3-large W3-display-
to right"> x </span> <div class = "W3-panel W3-border-top W3-border-
<p> click on the x to close this panel.</p> bottom">
<p> click on the x to close this panel.</p> <p> I have top and bottom borders.
</div> </p>
</body> </div>
</html> </div>
Output: </body>
</html>
Output:
(III) Colored List: W3.Color class is used to add (V) Closable List Item: Add span tag with a button
color to the list. You can create a colorful list by of list item, it displays cross. You can close/hide the up
changing the background of the table or individual items list item by clicking on 'x' (cross).
as per your choice. Example:
Example: <!DOCTYPE html>
<!DOCTYPE html> <html>
<html> <title> W3.CSS </title>
<title> W3.CSS </title> <meta name = "view port"
<meta name = "view port" content = "width = device-width, initial scale =1">
content = "width = device-width, initial-scale = 1"> <body>
<link rel = "style sheet" href = "W3.CSS"> <div class = "W3-container">
<body> <h2> Clasable List Items </h2>
<div class = "W3-container"> <p> to close/hide the list items, click on the "x":</p>
<h2> Colored List </h2> <ul class = "W3-ul W3.card-4">
<p> use any W3-color class to add a color to the <li class = "W3-display-container"> kindergarden
list:</p> <span on click = "this. Parent Element, style, display
<ul class = "W3-ul W3-red"> = "none" class "W3-button W3-transparent W3-
<li> Pizza </li> display-right"> & times;
<li> Burger </li> </span> </li>
<li> Dosa </li> <li class = "W3-dispalay-container"> school <span
</ul> on click = "this. Parent Element.style.display
<div> = "none" class = "W3-button W3-transpatent
</body> W3-display-right"> & times; </span> </li>
</html> <li class ="W3-display-container"> college
Output: <span on click = "this, parent Element, style,
display = 'none" class = "W3-button W3-
transparent W3-dislay-right"> & times;
display-right"> & times;
</span> </li>
</ul>
</div>
</body>
</html>
M2R5 97 YCT
Practice Questions with Explanatory Solutions
1. W3.CSS is a ........... Ans.(d) CSS frameworks are libraries that allows
(a) Website creating simple web designs using the Cascading Style
(b) DTP software Sheets language. The framework includes font size,
(c) Web publishing tool CSS reset, button styles, etc.
(d) Framework
6. One of the basic principles of W3.CSS is–
Ans.(d) W3.CSS is the most used framework for in- (a) Similarity for all browsers
built responsive website. The CSS Framework is a (b) Parity across all devices
library that allows standard compliment web design (c) Only Standard CSS
using the Cascading Style Sheets language. (d) All of the above.
2. How many columns are there in the basic grid Ans. (d) W3.CSS is equally useful for all browsers
box of the skeleton? and all types of devices (mobile, computer etc.) It uses
(a) 17 (b) 12 only standard CSS.
(c) 16 (d) 10
7. Which class is there to determine the color of text
Ans. (b) The grid box has 12 columns with a
element?
maximum width of 1200PX, which is smaller in size
(a) w3.text.color
to shrink with the browser or device. The max width
(b) w3.css text color
can also be changed with a single row of CSS. And
(c) w3.text color
the column sizes also change accordingly.
(d) w3.text.color
3. Which of the following classes is appropriate to
Ans. (a) The w3.text.color class is used to set the text
display quotes–
color of an element.
(a) w3-Panel class
(b) W3-Panel class 8. Which of the following class is used to set the
(c) W3-Container class background color displayed by W3.CSS?
(d) none of these (a) w3.color
(b) w3 background color
Ans. (b) W3-Panel is used to display class quotes.
(c) bg color
Quotes are often displayed with a background, a left
(d) w3.color
border bar, and an italic font style.
Ans.(c) Color is an important aspect of the view of a
4. Which of the W3-Container class is not used for
website. The website can be made more attractive by
HTML container elements?
selecting the right color combination. The w3.color
(a) <div>
(b) <span> class is used to set the background color for any
(c) <footer> HTML element.
(d) <item> 9. Which class is used in W3.CSS to set the
Ans. (b) W3-Container is used to store container type background color when the mouse is hovered
elements in W3.CSS framework. HTML containers over an element?
like <div>, <article>, <section>, <header>, <footer>, (a) w3 hover : color
<form> etc. are used under W3-container class. The (b) W3 color hover
W3.CSS container class adds 16PX padding to the left (c) w3 hover : color
and right sides of an HTML element. This is also used (d) w 3 hover color
for many styles. Container type elements have Ans. (d) There are two classes of color change on
uniform padding, margin, font, color, and alignment. mouse hover. The first is the w3 hover color class.
5. Which of the following is not included in the This happens when the mouse hovers over it. Class
framework– Sets the background color of an element. The second
(a) font size class is W3 Hover Text, which sets the text color
(b) CSS reset when the mouse is hovered over. That is, to set the
(c) button style background color when the mouse is hovered over an
(d) forms element, the W3 hover color class is used in W3.CSS.
M2R5 98 YCT
10. When creating a website with W3.CSS, there is 15. The suitable class for mono spaced font is–
no need for.............. (a) W3-Code
(a) JavaScript (b) W3-Quotes
(b) HTML (c) W3-Container
(d) W3-Panel
(c) W3.CSS Properties
(d) W3.CSS Attributes Ans.(a) W3-Code class is used to display the code in
readable mono spaced font.
Ans.(a) HTML, W3.CSS properties and W3.CSS
16. What is the default font size in W3.CSS?
attributes are required when creating a website with
(a) 10Px
W3.CSS. Designing a website with W3.CSS does not (b) 15Px
require JavaScript. (c) 20Px
11. W3.CSS can– (d) 25Px
(a) Speeding up and simplifying web development Ans. (b) The default font size in W3.CSS is 15PX.
(b) Slowing down web development There are eight classes in W3.CSS fonts which are
(c) Making web development complicated used to set font size and font styling. These eight
(d) None of the above classes are-W3 tiny, W3-small, w3-medium, w3-large,
w3xlarge, w3xxlarge, w3-xxx large, w3-jumbo.
Ans.(a) W3.CSS is One of the most used CSS
frameworks for built-in responsive websites. It is 17. How much padding does the W3-Container class
add to the left and right sides of an HTML
based on standard CSS. It makes web development
element?
faster and simpler. (a) 10Px
12. .............. class can handle all types of lists– (b) 15Px
(a) w3-List (c) 16Px
(b) w3-items (d) 20Px
(c) w3-ul Ans.(c) The W3-container class adds 16PX padding to
(d) w3-collections the right and left sides of an HTML element. The W3-
Container class is used to style the container type
Ans.(c) The simplest way to create a W3.CSS list is to
element.
create an ordered list and then add the W3-list class to
the "ul" tag. This makes a very basic list. all types of18. To Limit a responsive image to a maximum size,
It is used–
lists can be displayed using w3-ul classes.
(a) max-width property
13. ........... is a modern CSS framework with built-in (b) min width property
responsiveness– (c) high-width property
(a) Java (d) low-width property
(b) Perl Ans. (a) The max-width property is used to limit a
(c) W3.CSS responsive image to a maximum size.
(d) Python 19. W3-CSS is developed by?
Ans.(d) W3.CSS is a modern CSS framework with (a) http//.in
built-in responsiveness. It is based on plain CSS, (b) W3schools.com
(c) www.com
which makes it fast. It does not use any additional
(d) none of these
libraries.
Ans. (b) W3.CSS is a CSS developed by
14. The class is used for all types of alerts–
w3schools.com. It supports responsive mobile design
(a) W3-Notes by default.
(b) W3-Quotes
20. The default line spacing in W3-CSS is–
(c) W3-Container (a) single
(d) W3-Panel
(b) 1.3
Ans.(c) W3.CSS Panels are a type of container and in (c) 1.7
addition, panels add 16PX top and bottom margins (d) 1.5
and also add 16PX padding on the left and right sides. Ans.(d) The default line spacing in W3.CSS is 1.5. It
It is used to display notes, quotes, alerts, cards etc. provides one letter spacing.
M2R5 99 YCT
6 JAVASCRIPT AND ANGULAR JS
6.1 Introduction: • JavaScript has rich user interface designs like sliders.
JavaScript is called JS in programming language. It Angular JS is a full data-driven approach to
is an interpreted programming language with object developing web applications.
oriented capabilities. It is also called dynamic computer • JavaScript takes less time when fixing bugs and errors
programming language. JavaScript programs are called on a large scale. Angular JS takes more time than
scripts. By using this, different types of things can be JavaScript.
applied in the web page. Its scripts can be provided and • JavaScript gives us immediate response while running
executed as plain text. the application on the browser and Angular JS does not
JavaScript is one of the three main technologies of have this feature.
the World Wide Web, after HTML and CSS. All the
major websites use it which are available on the Internet 6.3 Client Side Scripting language:
because it enables interactive web pages, hence it is used Client side scripting is used to generate a code that
more in creating web applications. JavaScript is a client- can run on a browser (client end) without requiring
side scripting language whose source code is processed server side processing. This type of script is placed
by the server rather than the client's web browser. Using inside an HTML document. It is associated with a
JavaScript, you can add HTML to a web page, as well as language that is compatible with the browser. HTML,
change the existing content and modify the page style. It CSS and JavaScript languages are used for client side but
was originally developed to add dynamic and interactive JavaScript is the most used language for client side
scripting. It has the ability to run on any browser. The
elements to the website. It is an open and cross-platform
browser downloads that code permanently and processes
which aims to provide a better experience for the user.
it without the server. Scripting is used to check a user's
Just like PHP and ASP, JavaScript code can be inserted
form for errors before additional information is required
anywhere within the HTML of a web page. Cookies can and to change the content according to user input.
be obtained and set with the help of JavaScript. It is also
used to ask questions to visitors and display messages. Client Side Scripting Languages–
6.2 Javascript and Angular JS: • HTML: It provides frame to the website and describes
Following are the differences between JavaScript the content management.
and Angular JS– • CSS: It provides a way to design graphic elements that
(i) JavaScript is a client side scripting language as well makes more attractive to the appearance of a web
as a server side scripting language for creating web application.
applications. • JavaScript: It is client side scripting essentially
Angular JS is a framework written in JavaScript designed for specific purposes but currently various
for building single page applications. JavaScript frameworks are used as server side scripting
(ii) JavaScript is a language which is used to manipulate technology.
the document object model.
Angular extends its features with other 6.3(i) Advantages and Disadvantages of
technologies like JS, HTML. Client side Scripting Language:
• JavaScript has the facility to validate user input at the Following are the major advantages of client side
browser level before submitting the page. Angular JS scripting language–
is a good technology which is used as server side. • Client side scripting language is easy to learn and
• JavaScript makes websites more interactive. Angular understand.
JS makes building applications simple and intuitive • This language is very light and very easy to apply.
from the start. • It takes less time to edit the code.
• JavaScript is a multi-dimensional and complex • The execution process of this language is quite fast. In
language whereas Angular JS is simple and efficient. this, after the script is downloaded from the server, its
• JavaScript code is generally faster and Angular JS code is executed on the user's computer through the
applications are generally slower. browser.
• JavaScript does not support Dependency injection and • Client side scripting makes easler to complex tasks.
Angular JS does not support data binding and • It does not require any server to execute the code.
Dependency injection. • It takes less time to execute the code.
M2R5 100 YCT
• In this language the user gets immediate response. 6.4 Variables in Javascript:
Following are the major disadvantages of client side A variable is a type of container in which you can
scripting language– store values and the values are executed when the
• The biggest disadvantage of client side scripting is that program is run and the output is displayed. In JavaScript,
its code can be seen by anyone, due to which it is not variables are defined by var.
secure. To define variables in JavaScript, you can use
letters, numbers, underscore (_) or doller ($). Variables
• In this, it is difficult to transfer sensitive data over the
cannot be initialized with numbers. Keywords cannot be
internet.
used for variables and the name of the variable is case
• Client side scripting depends on the user's browser. If sensitive i.e. both Num and num are different. There is
for some reason the browser malfunctions, it will no need to define the datatype in JavaScript, it
affect it. automatically recognizes the data type of the variable.
• Debugging is difficult in this. There are two types of variables in JavaScript. Both
• It is quite difficult to maintain it. of these variables are used in different situations. Local
• It has less functions than server side scripting variables can be used only in any function and global
language. variables can be accessed from any function.
Example– Var x = 30;
Var is the keyword that tells JavaScript that you are
To add Javascript in HTML Page–The below
declaring a variable. The name of that variable is x.
example shows how JavaScript is used to write text on a = (equal to) is an operator that indicates JavaScript
web page. next upcoming value. 30 is the value of the variable to
store.
Example:
<html> Local Variables– Local variables are those variables
<body> whose scope is limited to any function. In such a
<script type = "text/javascript"> situation the variables are created inside a function and
document.write ("My First Javascript"); they work only in that function. You cannot use these
variables outside the function, when these variables are
</script>
created in a block or function they work only in what is
</body>
called their scope. An undefined variable error is
</html> generated if you try to access local variables outside their
The example given below shows how to add HTML scope.
tags in JavaScript– Example:
<html> <!DOCTYPE html>
<body> <html>
<script type = "text/javascript"> <head>
document.write ("<h1> My First Javascript </h1>"); <title> Local variable Example </title>
</script> </head>
</body> <body>
</html> <h2> Local variable Example </h2>
To add a JavaScript to an HTML page you can use <script>
var my var = "Local"; //Declare a local variable
the <script> tag, inside the <script> tag you can use the
docment.write (my var);
type attribute to define the scripting language. </script>
<script type = "text/javascript"> and </script> </body>
defines where the JavaScript starts and ends. </html>
Global Variables– Global variables are variables
<html> whose scope is in the entire program, so in such a
<body> situation, the variables are created at the beginning of the
<script type="text/javascript">..... program and you can use them anywhere in the entire
</script> program. The scope of such variables is the entire
</body> program.
</html> Example:
The document.write command is a JavaScript <!DOCTYPE html>
<html>
command to write output to a page.
<head>
By inputting the document.write command between
<title> Global varible Example </title>
the <script> and </script> tags, the browser recognizes it. <body>
Executes Javascript commands and code lines. <h2> Global variable Example </h2>
M2R5 101 YCT
<script> let age = 46 ;
var data = 400 ; || global variable function a ( ) { let Address = Banglore ;
document.writeln (data); //printing variable values
} document.write (name + "<br>">) ;
function b ( ) {
document.write (age + "<br>") ;
document.write In (data);
} document.write (address + "<br>") ;
a ( ); //calling Java script function //Declaring constant
b ( ); const PI = 3.14 ;
</script> //Printing constant value
</body> document.write (PI); //3.14
</html> </script>
</body>
Loosely Type Variables – JavaScript variables are
</head>
of loose type, that is, no data type is required to declare
it. You can specify any literal value to a variable. String, </html>
Integer, Float, Boolean etc.
Example: 6.5 Data Type in Javascript:
<!DOCTYPE html> There are two types of data types in Javascript–
<html> <body> (i) Primitive Data Type
<h1> Javascript Loosely-typed variables </h1> (ii) Non-primitive (reference) Data Type
<p id = "d1"> </p>
<script> (i) Primitive Data Type: There are five types in
var basket = 5; //Number value JavaScript – 1.String, 2. Number, 3. Boolean, 4. Null, 5.
basket = 7.33; //decimal value Underfined.
basket = null; //null value 1. String: Represents a sequence of string characters
basket = False; //boolean value like– "New", "Hello"
basket = 'basket' ; // string value 2. Number: Represents Number. Numeric Values
document.get Element by Id("d1".innerHTML= like– 200.
two); 3. Boolean: Represents Boolean values whether these
</script> values are False or True.
</body> 4. Null: Represents Null values and checks that there is
</html> no value.
5.Underfined: It represents underfined values.
Let & Const Keyword– Let keyword is also like
var but through it we can create block Scoped Variable. Example:
let variable can be updated but cannot be redeclared <!DOCTYPE html>
repeatedly in the same block like var, but the same
<html>
variable can be declared in different blocks.
If the value of a variable is to always be kept <head>
constant, that is, it is not to be changed, then in such a <title> primitive data type example </title>
situation constant variable is used. In this, once the value </head>
is assigned, it cannot be updated again. It cannot be re- <body>
declared. While declaring a const variable it is necessary <h2> primitive data type example </h2>
to assign a value to it. Const variable is also block scope, <p id ="demo" </p>
that is, it can be accessed only within the block within <script type ="text/javascript">
which it is declared. document.get element
By ID ("demo").inner HTML
Example:
type "John" + "<br"> +
<!DOCTYPE html>
type 3.14 + "<br>" + type of true + "<br>" +
<html>
type of false ;
<head>
</script>
<title> Declaring variables with let and const
</body>
keywords in Javascript </title>
</html>
</head>
Object: Object represents an instance through which
<body>
we can use numbers.
<script> //Declaring variables Reg Exp–Reg Exp– Represents a regular
let name ="Smith" ; expression.
M2R5 102 YCT
Array: Array represents a group of similar values. var d=-5.10;//Negative floating-point Numeric value
Example: document.write ("value of a is" + a +"<br/>");
<!DOCTYPE html> document.write ("value of b is" + b + "<br/>");
<html> document.write ("value of d is" + d + "<br/>");
<head> document.write ("value of c is" + c + "<br/>");
<title> Non-primitive Data Type Example </title> </script>
</head> Output:
<body> value of a is 5
<h2> Non-primitive data type example </h2> value of b is 5.1
<pid = "demo"> </p> value of c is -5
<script type = "text/javas script">
var my var = 100 ; Boolean data type– Boolean data type can have two
my var = true ; values TRUE and FALSE in Javascript and is used in
my var underfined ; conditional statements in the program. Conditional
my var = "steve" ; statements like– if else, while, do while, switch
alert (my var); Example:
</script> var yes = true;
</body> var no = false;
</html> <script type = "text/javascript">
var a = true;
String data type– Javascript string can be single var b = false;
character or character sequence. In JavaScript, strings </script>
can always be written in single quotes (' ') or (" ").
For example; Single quotes "double quote" Null: Null is a special value in JavaScript, which
Example: represents empty and unknown value.
let string1 = 'Hi this is single quote string"; We assign Null to a variable and there is no value in
let string2 = "Hi this is double quote string"; that variable. Null means no value.
Example:
Operators are used in Javascript to concatenate two var new var = null;
strings together. alert (new var);
Example:
let string1 = "javascript"; You can see in the above example that we have
let string2 = string1 + "news string"; assigned null to the variable of new var name. Which
//output:javascript newstring means we have assigned null to the variable but it does
<script type = "text/javascript"> not contain any value.
var strl = 'Hello'; //single quoted string Example:
var str2 = "world"; //Double quoted string <script type = "text/java script">
var str3 = " "; // Empty string var a = null;
document.write ("value of strl:" + strl + "<br/>"); document.write (a = = undefined);
document.write ("value of str2:" + str2 + "<br/>"); </script>
document.write ("value of str3:" + str3 + "<br/>"); Output:
</script> true
Output: var new var = null;
value of strl : Hello if (new var) {
value of str2 : World alert ("new var is not null");}
value of str3 : else {
alert ("new var is null");}
Number data type– Javascript number data type
represents integer, float, hexadecimal, octal number Undefined data type–Undefined data type in
value. The integral value can be positive or negative. JavaScript represents a value not assigned to a variable.
Example: This means that the variable has been declared but no
var int = 50; // integer value has been assigned to it. Due to that the value of
var float = 50.5 // float value that variable is called undefined.
var hex = Oxfff; Undefined is a primitive value. Variable and object
var octal = O40; has undefined value when we use it before assigning the
<script type = "text/java script"> value.
var a = 5; //Integer Numeric value Example:
var b = 5.10; //floating-point Numeric value var new var;
var c = -5; //Negative Integer Numeric value alert (new var);
M2R5 103 YCT
You can see in the above example that if we have (i) Arithmetic Operators– Arithmetic operators
not assigned any value to the variable of new var name, are used to perform arithmetic calculations. It takes the
then it will undefined. form of operands (values/variables) and returns a single
Example: value. +, – *, /, % ++, – – operators are called arithmetic
function sum (value1, value2) operators. If two numeric values are x = 10, y = 5 then,
{ Operators Description Example Output
var result = value1 + value2; + Addition x+y 15
}
var result = sum (5, 5); – Subtraction x–y 5
alert (result); //undefined * Multiplication x*y 50
In the above example you can see that in the sum( ) / Division x/y 2
function we have passed (5, 5) value to the function, but % Modulus x%y 0
in the function If we do not return that value operation
++ Increment ×++ 11
then it will return us undefined value in the result.
(increase
Non-primitive Data Type– Non-primitive Data
operand
Type object, can be Array and RegExp, object
value by
Represents the instance through which we can use
one)
Numbers.
Array is used to represent values of the same type, –– Decrement ×–– 9
whereas Reg. Exp represents a regular expression. (Decrease
Object: It represents an instance through which we operand
can use numbers. value by
Reg Exp–Reg Exp represents a regular expression. one)
Array–Array represents a group of similar values. Example:
Example: <html>
<html> <head>
<head> <script type ="text/java script"> <!–
<title> Non-Primitive Data Type Example </title> var a = 33;
</head> var b = 10;
<body> var link break ="br/>";
<h2> Non-primitive Data Type Example </h2> document.write ("a + b =");
<p id = "demo"> </p> result = a+b;
<script type = "text/java script"> document.write (result);
var my var = 100; document.write (line break);
my var = true; document.write ("a-b=");
my var = null; result = a–b;
my var = undefined; document.write (result);
my var = "steve"; document.write(line break);
alert (my var); document.write("a/b=");
</script> result = a/b;
</body> document.write (result);
</html> document.write (line break);
6.6 Operators in Javascript: document.write ("a%b=");
Operator is a special symbol in JavaScript used for result = a%b;
manipulating variables values which is used for docment.write (result);
manipulating JS variables values. They are used only to document.write (line break);
perform operations on operands. document write ("a+b+c=");
There are following types of operators in result = a+b+c;
JavaScript– document.write (result);
i. arithmetic operator
document.write (line break);
ii. assignment operators
iii. Comparison Operator / Relational Operator a = + + a;
iv. Logical operator document.write ("++a=");
v. String operator result = ++a;
vi. Bitwise operator document.write (result);
vii. Special Operator document.write (line break);
viii. Type of operator b+-b;
M2R5 104 YCT
document.write ("-b="); Example:
result = --b; <html>
document.write (result); <head>
document.write (line break); <script type = "text/javascript"> <!...
//....> var a = 33;
</script> var b = 10;
set the variables to different values and then try... var line break = "<br/>";
</body> document.write ("value of a = > (a = b) = >");
</html> result = (a + b);
Output: document.write (result);
a+b = 43 document.write (line break);
a-b = 23 document.write ("Value of a = > (a + b = b) = >");
a/b = 3.3 result = (a + = b);
a%b = 3 document.write (result);
a+b+c = 43 Test document.write (line break);
++ a = 35 document.write (line break);
..b = 8 document.write ("value of a = > (a – = b) = >");
Set the variables to different values and then try.... result = (a-=b);
document.write (result);
(ii) Assignment Operators– This operator is used document.write (line break);
to assign values to variables. = is assign operator which docment.write ("value of a => (a*=b)=>");
is used to assign the value of variable x. It assigns a result = (a*=b);
value to the left operand. Equals Controller (=) is used to document.write (result);
assign the value, = , + = , – =, * = , % = operators are document.write (line break);
called assignment operators.
document.write ("value of a => (a/=b)=>");
Taking x = 10, y = 5.
result = (a/=b);
Operators Description Example Output
document.write (result);
Assigns one document.write (line break);
operand to x=y document.write ("value of a = > (a%=b)= >");
= another. x=y x=5 result = (a%=b);
Sum of x=x+y document.write (result)
operands and x = 10+5 document.write (line break);
+= finally assign x+=y x = 15 //-->
to the left </script>
operand </body>
Subtraction x=x–y </html>
and assign the x =10 – 5 Output:
–= left operand in x–=y x=5 value of a = > (a = b) = > 10
the end value of a = > (a + b) = > 20
Multiplication x=x*y value of a = > (a = b) = > 10
of operands value of a = > (a * = b) = > 100
x =10 × 5 value of a = > (a / = b) = > 10
*= and finally x*=y x = 50 value of a = > (a % = b) = > 0
Assigns to the Conditional Operator (?:)
left operand. The conditional operator first evaluates an
Division of the expression for a true or false value and then executes one
operand and x=x*y of the two given statements depending upon the result of
/= finally assigns x*=y x = 10×5 the evaluation.
to the left x = 50 Sr.No Operator and Description
operand 1
Modulus of the ?: (conditional)
operand and x=x%y If condition is true? Then value x: otherwise value y
%= finally assigns x%=y x =10 %5 Example:
it to the left x=0 <html>
operand. <body>
<script type = "text/javascript"> <!--
M2R5 105 YCT
var a = 10; Example:
var b = 20; <html>
var link break = "<br/>"; <head>
document.write ("((a > b) ? 100 : 200) = >"); <script type ="text/javascript"> <!--
result = (a > b)? 100:200; var a = 10;
document.write (result);
var b = 20;
document.write (line break);
var line break ="<br/>";
document.write ("((a < b) ? 100 : 200) = >");
result = (a < b) ? 100 : 200; document.write ("(a= =b)=>");
document.write (result); result = (a= =b);
document.write (line break); document.write (result);
//--> document.write (line break);
</script> docment.write ("(a<b)=>");
<p> set the variables to different values and result = (a<b);
different operators and then try... document.write (result);
</p> document.write (line break);
</body> document.write ("(a>b)=>");
</html> result = (a>b);
Output:
document.write (line break);
((a>b)? 100:200) = > 200
((a<b)? 100:200) = > 100 docment.write ("(a! = b)=>");
Set the variables to different values and different result = (a!=b);
operators and then try... document.write (result);
document.write (line break);
(iii) Comparison Operators– It determines the two document.write ("(a>=b)=>">;
operands that satisfy the given condition. It compares result = (a> = b);
two values then returns a Boolean value True or False. = document.write (result);
=, = = = ! =, ! = =, <, >, > =, < = operators are called document.write (line break);
comparison operators. document.write("(a<=b=)=>");
result = (a<=b);
Operator Name Example Result document.write (line break);
== equal x==y True; If x is //-->
equal to y. </script>
True: If x is </body>
equal to y </html>
=== same x===y and they Output:
belong to the
(a= =b) = > false
same type.
(a < b) = > true
True; If x is (a > b) = > false
!= equal not x! = y not equal to
(a! = b) = > true
y.
(a > = b) = > false
True: If y is a < = b) = > true
not equal or
the variables (iv) Special Logical Operators– Logical operators
!== same not x!==y are generally used with Boolean values hence they are
are not of the
same type. called logical. These can be applied to any type of values
&&, ||, ! are called logical operator.
True; If x is
< less than x<y less than y.
Operator Name Example Result
greater True; If x is
True; If both
> than x>y greater than
y. && AND x && y x and y are
true.
greater or True: If x is
>= equal to x>=y greater than || OR x || y True; if x or
or equal to y. y both are
less or True; If x is correct
<= equal to x<=y less than or ! NOT !x True; If x is
equal to y. not true.
15. ............ is the first browser to support JavaScript. 20. Which keyword is used to declare variables in
JavaScript?
(a) IE (b) Netscape (a) caps (b) scap
(c) Google Chrome (d) Mozilla Firefox (c) var (d) &
Ans.(b) JavaScript was first used in Netscape browser Ans.(c) Information is stored at one place in
version 2.083 in December 1995, netscape JavaScript variables. Any type of value is stored in a
variable. “Var” keyword is used to declare the
communicator, which was NCSA's first browser. It
variable. While declaring the variable, any letter (A-Z)
became quite popular but later its popularity decreased (1-2), underscore (_) or dollar ($) can be used as the
significantly after Microsoft created Internet Explorer. first character.