Web Viva Questions
Web Viva Questions
2. What is HTML?
Answer: HTML (Hypertext Markup Language) is the standard markup language used
to create and structure content on the web. It defines the structure of web pages using
elements like headings, paragraphs, links, images, etc.
3. What is CSS?
Answer: CSS (Cascading Style Sheets) is a stylesheet language used to describe the
presentation or layout of a document written in HTML. CSS controls the design,
colors, fonts, spacing, and positioning of web page elements.
4. What is JavaScript?
Answer: The DOM is a programming interface for web documents. It represents the
structure of a document as a tree of nodes, where each node corresponds to a part of
the document (elements, attributes, text, etc.). JavaScript can manipulate the DOM to
dynamically update the content and structure of a webpage.
Answer: HTTP (Hypertext Transfer Protocol) is the protocol used to transfer data
between a web server and a client. HTTPS (HTTP Secure) is the secure version of
HTTP that uses encryption (SSL/TLS) to protect data during transmission. HTTPS
ensures confidentiality and integrity of data between the server and client.
Answer: A web server is a software that handles HTTP requests from clients
(typically browsers) and serves them web pages (HTML, CSS, JavaScript files) and
other resources (images, videos, etc.) over the internet.
9. What is AJAX?
Answer: A web browser is a software application used to access and view websites
on the internet. It interprets and renders HTML, CSS, JavaScript, and other resources
to display content to users. Popular browsers include Google Chrome, Mozilla
Firefox, Safari, and Microsoft Edge.
Answer: Responsive Web Design (RWD) is an approach to web design that makes
web pages render well on a variety of devices and window sizes (desktops, tablets,
and smartphones). It uses CSS media queries to adjust the layout based on the screen
size or device characteristics.
Answer:
o id: The id attribute is used to uniquely identify an element in the HTML
document. It should be used for one element only and is accessed via
JavaScript and CSS.
o class: The class attribute is used to assign one or more classes to elements,
allowing multiple elements to share the same styles.
Answer: Web APIs (Application Programming Interfaces) are a set of rules and
protocols that allow different software applications to communicate with each other.
In web development, APIs allow the exchange of data between a client and a server,
often in JSON or XML format.
17. What is the difference between GET and POST methods in HTTP?
Answer:
o GET: The GET method is used to retrieve data from the server. It appends the
data to the URL and is visible in the browser’s address bar. It is safe and
idempotent (does not modify data).
o POST: The POST method is used to send data to the server, such as form
data. It sends the data in the body of the request, making it more secure than
GET. It is typically used for actions like submitting forms or uploading files.
Answer: A CDN is a system of distributed servers that deliver web content, such as
images, videos, and stylesheets, to users based on their geographic location. CDNs
reduce latency and improve the speed of content delivery to users worldwide.
1. What is HTML?
Answer: HTML tags are the building blocks of HTML. They define different
elements of a webpage. Tags are enclosed in angle brackets, like <tagname>.
Common tags include <html>, <head>, <body>, <p>, and <a>.
Answer:
o <div>: A block-level element used for grouping larger sections of content. It
creates a new block and takes up the full width of the parent container.
o <span>: An inline element used for grouping smaller portions of content like
text. It does not break the flow of content and only takes up as much width as
needed.
Answer: The <head> tag contains meta-information about the HTML document, such
as the title, links to stylesheets, scripts, and other metadata like charset and author.
Answer: The <meta> tag provides metadata about the HTML document, such as the
character set, author, description, and keywords. It is typically placed inside the
<head> section.
Answer: The <a> tag is used to create hyperlinks. It allows users to click and
navigate to other pages or resources. The href attribute specifies the URL of the link.
o Example: <a href="https://example.com">Click here</a>
Answer:
o <ol>: Represents an ordered list, where each list item is numbered.
o <ul>: Represents an unordered list, where each list item is marked with a
bullet point.
8. What is the <form> tag used for in HTML?
Answer: The <form> tag is used to create HTML forms for collecting user input. It
contains form elements such as text fields, checkboxes, radio buttons, submit buttons,
etc.
Answer: Attributes provide additional information about HTML elements. They are
always written inside the opening tag and are used to configure or modify the
behavior of an element. For example, href in the <a> tag or src in the <img> tag.
10. What is the purpose of the alt attribute in the <img> tag?
Answer: The alt (alternative text) attribute provides a textual description of an image,
which is displayed if the image cannot be loaded. It also helps with web accessibility,
describing images to visually impaired users.
CSS Questions
1. What is CSS?
Answer: CSS (Cascading Style Sheets) is a stylesheet language used to define the
presentation of HTML elements. It controls the layout, colors, fonts, spacing, and
overall design of a webpage.
Answer: Selectors are patterns used to select HTML elements for applying styles.
Examples of selectors include element selectors (e.g., p, h1), class selectors (e.g.,
.class-name), and id selectors (e.g., #id-name).
Answer:
o Class selectors: Used to select multiple elements with the same class. Syntax:
.classname
o ID selectors: Used to select a unique element with a specific ID. Syntax:
#idname
o A class can be applied to multiple elements, while an ID should be unique to a
single element.
Answer: The box-sizing property defines how the total width and height of an
element are calculated. With box-sizing: border-box, padding and borders are
included in the element’s width and height. The default value, content-box, excludes
them.
Answer: The z-index property specifies the stack order of elements. Higher values are
displayed in front of lower values. It is used for positioning elements along the z-axis
(depth) when elements overlap.
Answer: The float property is used to position elements to the left or right of their
container, allowing other content to wrap around them. It is commonly used for text
wrapping around images.
Answer: The position property defines how an element is positioned within its
container. Values include:
o static: Default positioning (normal flow of the document).
o relative: Positioned relative to its normal position.
o absolute: Positioned relative to the nearest positioned ancestor.
o fixed: Positioned relative to the viewport, staying fixed when scrolling.
o sticky: A hybrid between relative and fixed positioning.
Answer: The display property determines how an element is displayed on the page.
Common values include:
o block: The element takes up the full width, creating a new block.
o inline: The element takes up only as much space as needed, without breaking
the flow.
o inline-block: Similar to inline, but allows for setting width and height.
o none: The element is not displayed (it’s hidden).
Answer: Flexbox is a layout model in CSS that allows for more efficient arrangement
and alignment of elements within a container, even when their sizes are unknown or
dynamic. It provides powerful options for centering, spacing, and distributing space
within a container.