Front End Web Q&a
Front End Web Q&a
Here
are some common types:
1. CSS Animations with JavaScript: You can manipulate CSS properties via JavaScript to
trigger CSS animations. For example, adding or removing classes that contain
@keyframes animations.
2. JavaScript Animation Libraries:
o GSAP (GreenSock Animation Platform): Offers powerful and flexible tools for
creating complex animations.
o Anime.js: A lightweight library for animating CSS properties, SVG, and DOM
elements.
o Three.js: Mainly for 3D graphics but also includes animation features for 3D
objects and scenes.
3. Canvas Animations: Using the HTML5 <canvas> element, you can draw and animate
graphics directly. This is often used for games or complex visualizations.
4. SVG Animations: JavaScript can be used to animate SVG graphics. Libraries like
Snap.svg or directly manipulating SVG attributes with JavaScript are common
approaches.
5. RequestAnimationFrame: A native JavaScript method that allows you to create smooth
animations by calling a function before the next repaint. It’s more efficient than using
setTimeout or setInterval for animations.
6. Web Animations API: Provides a standard way to create animations directly within the
browser, allowing for complex animations and better performance compared to
traditional methods.
(a) Factors to Consider When Building a Website for a Business Enterprise (2 marks):
1. Target Audience: Understand the needs and preferences of the target audience to ensure
the website meets their expectations and provides a good user experience.
2. Functionality: Determine the essential features and functionalities required, such as e-
commerce capabilities, contact forms, or customer support tools.
3. Design and Branding: Ensure the website aligns with the company’s branding and
provides a visually appealing and cohesive design that reflects the business's identity.
4. Mobile Responsiveness: Make sure the website is optimized for different devices and
screen sizes to provide a seamless experience across desktops, tablets, and smartphones.
(ii) Uses of the Common Gateway Interface (CGI) in Web Authoring (2 marks):
1. Form Processing: CGI scripts can handle form submissions by processing user input and
sending the data to a server for processing, often used for handling user registration or
feedback forms.
2. Dynamic Content Generation: CGI can generate dynamic web pages based on user
interactions or database queries, allowing for real-time content updates and personalized
user experiences.
1. Client-side Programming: This involves code that runs in the user's browser (e.g.,
JavaScript, HTML, CSS). It’s used to create interactive elements on the webpage, handle
user interactions, and provide instant feedback without needing to communicate with the
server.
o Example: Form validation, animations, and dynamic content updates using
JavaScript.
2. Server-side Programming: This involves code that runs on the web server (e.g., PHP,
Python, Ruby). It’s used to handle requests from the client, interact with databases, and
generate the web pages that are sent to the client.
o Example: User authentication, database queries, and generating dynamic web
pages based on server-side logic.
(ii) JavaScript Function to Prompt for a Color and Set Link Color (4 marks):
java script
Copy code
function setLinkColor() {
// Prompt the user to enter a color
var color = prompt("Enter a color for the links:");
1. Lossless Compression: PNG uses lossless compression, which means that image quality
is preserved, and no data is lost during compression. This is ideal for images that require
high detail and clarity, such as logos or graphics with text.
2. Transparency Support: PNG supports transparency with its alpha channel, allowing for
images with transparent backgrounds or semi-transparent areas. This feature is useful for
overlaying images on different backgrounds or creating smooth visual effects.
3. Wide Color Range: PNG supports a wide range of colors, including 24-bit true color (16
million colors) and grayscale, which makes it suitable for detailed and colorful images.
This is particularly useful for images with gradients or complex color schemes.
CGI (Common Gateway Interface) is a standard protocol used to enable web servers to interface
with external programs or scripts. These scripts, often written in languages like Perl, Python, or
PHP, run on the server to generate dynamic web content. The primary functions of CGI include:
1. Processing Form Data: CGI scripts can handle data submitted through web forms,
process it, and generate responses based on that data.
2. Generating Dynamic Content: CGI enables the creation of web pages that are
dynamically generated based on user input or other server-side conditions.
1. link Attribute:
o Purpose: Specifies relationships between the current document and external
resources. Commonly used in the <head> section to link to stylesheets.
o Example: <link rel="stylesheet" href="styles.css">
2. vlink Attribute:
o Purpose: Defines the color of visited links in a document.
o Example: <body vlink="#800080">
3. alink Attribute:
o Purpose: Sets the color of active links (links that are currently being clicked).
o Example: <body alink="#ff0000">
Advantages of Using Server-Side Programs for Web Applications (6 marks):
1. Enhanced Security: Server-side programs can handle sensitive operations and data
securely on the server, reducing exposure to security vulnerabilities compared to client-
side processing.
2. Database Interaction: Server-side scripts can interact directly with databases to retrieve,
insert, or update data, which is essential for applications requiring data management.
3. Dynamic Content Generation: They enable the creation of dynamic web content based
on user inputs or interactions, which can be customized in real-time according to user
needs.
1. PHP: Widely used for web development to handle server-side logic, interact with
databases, and generate dynamic web content.
2. Python (Django/Flask): Python-based frameworks like Django or Flask are used for
building web applications and handling server-side operations.
3. Ruby (Ruby on Rails): A popular framework for developing web applications, handling
backend logic, and managing databases.
If the text formatting options are, for example, bold, italic, and underlined, the HTML statements
would be:
html
Copy code
<b>Bold Text</b>
<i>Italic Text</i>
<u>Underlined Text</u>
1. <address>: Used to provide contact information for the author or owner of a document.
o Example: <address>123 Main St, Anytown, USA</address>
2. <s>, <strike>, <del>: Used to represent text that has been deleted or is no longer
relevant.
o Example: <s>Old text</s>
3. <samp>: Represents sample output from a computer program.
o Example: <samp>Result: 42</samp>
1. Lossless Compression: PNG uses lossless compression, which retains the original
quality of the image without any data loss.
2. Transparency: Supports transparent backgrounds and semi-transparency, which is useful
for creating images with transparent or partially transparent areas.
3. High Color Depth: Supports 24-bit color, allowing for high-quality images with a wide
range of colors.
Checkboxes:
o Purpose: Allow users to select multiple options from a set.
o Example: <input type="checkbox" name="option1" value="value1"> Option 1
Radio Buttons:
o Purpose: Allow users to select only one option from a set of mutually exclusive
options.
o Example: <input type="radio" name="group1" value="value1"> Option 1
html
Copy code
<!DOCTYPE html>
<html>
<head>
<title>Pattern Generator</title>
</head>
<body>
<script>
function generatePattern() {
let pattern = '';
for (let i = 1; i <= 5; i++) {
pattern += '*'.repeat(i) + '<br>';
}
document.body.innerHTML = pattern;
}
generatePattern();
</script>
</body>
</html>
JavaScript Function to Prompt for Color and Set Link Color (4 marks):
javascript
Copy code
function setLinkColor() {
var color = prompt("Enter a color for the links:");
if (color) {
var links = document.querySelectorAll('a');
links.forEach(function(link) {
link.style.color = color;
});
}
}
Benefits of Using a Website for Advertising (4 marks):
1. Increased Visibility: A website allows the company to reach a broader audience beyond
local or physical limitations.
2. Cost-Effective Marketing: Digital advertising can be more affordable compared to
traditional marketing methods like print or TV ads.
3. 24/7 Availability: A website provides continuous access to information about the
company's products or services, regardless of time.
JavaScript Code to Display Numbers Less Than 20 and Their Sum (7 marks):
html
Copy code
<!DOCTYPE html>
<html>
<head>
<title>Numbers Less Than 20</title>
</head>
<body>
<script>
let sum = 0;
let output = "Numbers less than 20: <br>";
document.write(output);
document.write("<hr>");
document.write("Sum: " + sum);
</script>
</body>
</html>
Cross-Site Scripting (XSS) is a vulnerability that allows attackers to inject malicious scripts
into web pages viewed by other users. This can lead to data theft, session hijacking, or
redirection to malicious websites. XSS attacks exploit the trust a user has in a particular site,
allowing the attacker to execute scripts in the context of that site.
Broken Authentication and Session Management occurs when web applications fail to
properly manage user authentication and session management, leading to vulnerabilities such as
session hijacking or unauthorized access. This can happen due to weak password policies,
insecure session identifiers, or improper handling of session timeouts and expirations.
html
Copy code
<!DOCTYPE html>
<html>
<head>
<title>Contact Form</title>
</head>
<body>
<form action="/submit" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name"><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email"><br>
<label for="message">Message:</label><br>
<textarea id="message" name="message"></textarea><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
1. Internal Links: Links that navigate to different sections or pages within the same
website.
2. External Links: Links that navigate to resources or pages on other websites.
3. Anchor Links: Links that navigate to specific parts of the same page or document.
4. Mailto Links: Links that open the user’s email client to send an email.
1. Usability Test: Evaluates how user-friendly and intuitive a website is by testing its ease
of use with real users.
2. Performance Test: Assesses how well a website performs under various conditions,
including load times, responsiveness, and handling of multiple users.
html
Copy code
<!DOCTYPE html>
<html>
<head>
<title>Display Names</title>
</head>
<body>
<script>
let names = ["John", "Ann", "Aaron", "Edwin"];
for (let i = 0; i < names.length; i++) {
document.write(names[i] + "<br>");
}
</script>
</body>
</html>
1. Home Page:
o Function: The main landing page of a website, often providing an overview of
the site’s content and navigation to other sections. It sets the tone for the user
experience and serves as the entry point for visitors.
2. Web Browser:
o Function: Software used to access and display web pages on the Internet. It
interprets HTML, CSS, and JavaScript to render webpages as intended by the
developer.
3. Web Server:
o Function: A server that hosts websites and delivers web pages to users over the
Internet. It processes requests from clients (browsers) and serves the requested
web pages or resources.
html
Copy code
<!DOCTYPE html>
<html>
<head>
<title>Country Dropdown</title>
</head>
<body>
<form action="/submit" method="post">
<label for="countries">Select a country:</label>
<select id="countries" name="countries">
<option value="kenya">Kenya</option>
<option value="uganda">Uganda</option>
<option value="tanzania">Tanzania</option>
<option value="rwanda" selected>Rwanda</option>
</select>
<input type="submit" value="Submit">
</form>
</body>
</html>
1. Cross-Platform:
o Explanation: Refers to web applications or pages that work across different
operating systems and devices without modification. Ensures compatibility with
various browsers and devices.
2. Interactive:
o Explanation: Web pages that engage users through interactive elements like
forms, buttons, or dynamic content updates. They respond to user actions,
providing a more engaging experience.
3. Dynamic:
o Explanation: Web pages that generate content in real-time based on user
interactions or data from a server. Unlike static pages, dynamic pages can change
their content without reloading the entire page.
html
Copy code
<!DOCTYPE html>
<html>
<head>
<title>Reverse Array</title>
</head>
<body>
<script>
let values = [1, 2, 3, 4, 5];
values.reverse(); // Reverse the array
for (let i = 0; i < values.length; i++) {
document.write(values[i] + "<br>");
}
</script>
</body>
</html>
1. mailto::
o Explanation: A URL scheme used to open the user's default email client to
compose an email.
o Example: mailto:[email protected]
2. gopher::
o Explanation: An obsolete URL scheme used for the Gopher protocol, which was
an early system for distributing, searching, and retrieving documents over the
Internet.
o Example: gopher://gopher.example.com
1. JPEG:
o Description: A commonly used format for photographic images that offers a
good balance between file size and image quality through lossy compression.
2. PNG:
o Description: A format that supports lossless compression and transparency,
making it ideal for images that require high quality and transparency features.
Consistent Layout in Web Design (4 marks):
HTML Code for Table with Border and Cell Spacing (6 marks):
html
Copy code
<!DOCTYPE html>
<html>
<head>
<title>Table with Border and Spacing</title>
<style>
table {
border-collapse: separate;
border-spacing: 2px; /* Spacing between cells */
border: 1px solid black; /* Border around the table */
}
th, td {
border: 1px solid black; /* Border around table cells */
padding: 5px; /* Padding inside cells */
}
</style>
</head>
<body>
<table>
<tr>
<th>Accommodation</th>
<th>University</th>
<th>Rank</th>
</tr>
<tr>
<td>Board</td>
<td>University</td>
<td>Rank</td>
</tr>
<tr>
<td>4000 per month</td>
<td>Example University</td>
<td>1</td>
</tr>
</table>
</body>
</html>
1. Performance: Evaluate the hosting provider’s server speed and uptime reliability to
ensure your website performs well and remains accessible.
2. Support: Look for a provider that offers reliable customer support with multiple contact
options like live chat, phone, or email.
3. Scalability: Choose a hosting service that can scale resources as your website grows,
allowing for easy upgrades as needed.
html
Copy code
<!DOCTYPE html>
<html>
<head>
<title>Event Handler</title>
<script>
function displayText() {
document.getElementById("message").innerText = "Click Me";
}
function showMessage() {
alert("On Click");
}
</script>
</head>
<body>
<button onclick="displayText()">Click Me</button>
<p id="message"></p>
<script>
document.getElementById("message").addEventListener("click", showMessage);
</script>
</body>
</html>
1. Internet:
o Definition: A global network of interconnected computers that communicate
using standardized protocols (like TCP/IP) to share information and resources.
2. Protocols:
o Definition: Rules and conventions for communication between network devices.
Examples include HTTP (HyperText Transfer Protocol) and FTP (File Transfer
Protocol).
1. Usability Testing: Assesses how easy and intuitive a website is to use. It involves real
users interacting with the site to identify usability issues.
2. Performance Testing: Measures how well a website performs under various conditions,
including load times and handling multiple users. It ensures the site is responsive and
reliable.
3. Security Testing: Identifies vulnerabilities and weaknesses in a website to protect
against potential threats and attacks. It includes tests for data protection and access
control.
html
Copy code
<!DOCTYPE html>
<html>
<head>
<title>ASP Example</title>
</head>
<body>
<%
Dim timeOfDay
timeOfDay = TimeOfDay()
If Hour(timeOfDay) < 12 Then
Response.Write("Good Morning")
Else
Response.Write("Good Afternoon")
End If
%>
</body>
</html>
Question 1:
(a) Outline four factors to consider when building a website for a business enterprise.
Answer:
1. Target Audience: Understand the needs and preferences of the target audience to design
a user-friendly interface.
2. Responsive Design: Ensure the website is accessible and functional on various devices
and screen sizes.
3. SEO Optimization: Implement SEO practices to enhance the website’s visibility in
search engine results.
4. Security: Implement measures to protect the website from security threats, including
secure data transmission and user authentication.
(b) State two uses of the Common Gateway Interface (CGI) in web authoring.
Answer:
1. Form Processing: CGI scripts handle user input from web forms and process the data
accordingly.
2. Database Access: CGI can interact with databases to retrieve and display information
dynamically on web pages.
(ii) Write a JavaScript function that prompts a user to enter a color. The function then
uses the color entered to set the link color within the existing web page.
Answer:
html
Copy code
<!DOCTYPE html>
<html>
<head>
<title>Change Link Color</title>
<style>
a { color: black; }
</style>
</head>
<body>
<a href="#">This is a link</a>
<script>
function changeLinkColor() {
let color = prompt("Enter a color:");
if (color) {
document.querySelector('a').style.color = color;
}
}
changeLinkColor();
</script>
</body>
</html>
(b) Maria, a web designer, inserted images on a website using Portable Network Graphics
(PNG) file format. Explain three benefits of this file format.
Answer:
1. Lossless Compression: PNG uses lossless compression, preserving the image quality
without loss of detail.
2. Transparency Support: PNG supports transparency, allowing for images with
transparent backgrounds.
3. High Quality: PNG is ideal for images with sharp edges and text, maintaining high
quality and clarity.
Question 3:
(i) <head>
Contains metadata about the HTML document, such as the title and links to stylesheets or
scripts.
(ii) <link>: Specifies relationships between the current document and external resources,
typically used to link to stylesheets.
(iii) <style>
Contains CSS rules to style the HTML document directly within the HTML file.
(c) Write HTML code that would be used to display on the browser the following list of
countries: Kenya, Uganda, Tanzania, Rwanda in a dropdown list with the country Rwanda
selected, and a submit button.
html
Copy code
<!DOCTYPE html>
<html>
<head>
<title>Country Dropdown</title>
</head>
<body>
<form action="/submit" method="post">
<label for="countries">Select a country:</label>
<select id="countries" name="countries">
<option value="kenya">Kenya</option>
<option value="uganda">Uganda</option>
<option value="tanzania">Tanzania</option>
<option value="rwanda" selected>Rwanda</option>
</select>
<input type="submit" value="Submit">
</form>
</body>
</html>
Question 4:
(a) State HTML tags that would help a web developer perform each of the following tasks:
1. href: Specifies the URL of the page linked to an anchor (<a>) tag or other link elements
like <link>.
Question 5:
(i) Cross-Platform:
Content that works across various operating systems and devices without modification.
(ii) Interactive:
Content that allows user engagement and interaction, such as forms, buttons, or dynamic
updates.
(iii) Dynamic:
Content that changes based on user interactions or real-time data, providing a personalized
experience.
(b) Write JavaScript that creates an array to store the values 1 through 5 and prints
elements in the array in reverse order.
html
Copy code
<!DOCTYPE html>
<html>
<head>
<title>Reverse Array</title>
</head>
<body>
<script>
let values = [1, 2, 3, 4, 5];
values.reverse(); // Reverse the array
for (let i = 0; i < values.length; i++) {
document.write(values[i] + "<br>");
}
</script>
</body>
</html>
(i) mailto:
Opens the default email client to compose an email to the specified address.
(ii) gopher:
An obsolete URL scheme for the Gopher protocol, used for retrieving documents and data before
the advent of the web.
Question 6:
(a) Anita likes to include images on a web page. Describe two types of image files she is
likely to use.
1. JPEG (Joint Photographic Experts Group): Suitable for photographic images, offering
good compression with some loss of quality.
2. PNG (Portable Network Graphics): Ideal for images that require transparency and
lossless compression.
(b) One of the factors to consider when designing a website is a consistent layout. Explain
this term and its importance in web design.
Consistent Layout refers to maintaining uniform design elements across different pages of a
website, such as colors, fonts, and navigation structures. It is crucial for providing a cohesive
user experience and ensuring that visitors can easily navigate and understand the website.
Question 7:
(a) Write HTML code to display a table with a border width of 2px and cell spacing of 5px
between cells.
Answer:
html
Copy code
<!DOCTYPE html>
<html>
<head>
<title>Table with Border and Spacing</title>
<style>
table {
border-collapse: separate;
border-spacing: 5px; /* Cell spacing */
border: 2px solid black; /* Border width */
}
th, td {
border: 2px solid black; /* Border around cells */
padding: 5px; /* Padding inside cells */
}
</style>
</head>
<body>
<table>
<tr>
<th>Accommodation</th>
<th>University</th>
<th>Rank</th>
</tr>
<tr>
<td>Board</td>
<td>University</td>
<td>Rank</td>
</tr>
<tr>
<td>4000 per month</td>
<td>Example University</td>
<td>1</td>
</tr>
</table>
</body>
</html>
Question 8:
(a) Explain three phases a web designer should consider during the design of a website.
1. Planning: Define the website’s goals, target audience, and content requirements. Create a
sitemap and wireframes to outline the structure.
2. Design: Develop the visual layout, including color schemes, typography, and graphics.
Create mockups and prototypes.
3. Implementation: Build the website using HTML, CSS, JavaScript, and other
technologies. Test for functionality and compatibility before deployment.
(b) Write a JavaScript program embedded in HTML that uses an event handler on click to
display the word "Click Me" on the screen. When the word is clicked, it displays the string
"Clicked!"
html
Copy code
<!DOCTYPE html>
<html>
<head>
<title>Click Event</title>
</head>
<body>
<p id="clickMe" onclick="handleClick()">Click Me</p>
<script>
function handleClick() {
document.getElementById("clickMe").innerText = "Clicked!";
}
</script>
</body>
</html>
(d) A university website has been experiencing frequent web attacks. Explain three such
attacks it is likely to experience.
Answer:
1. Cross-Site Scripting (XSS): Attackers inject malicious scripts into web pages viewed by
other users, potentially stealing sensitive information or manipulating the page content.
2. SQL Injection: Attackers exploit vulnerabilities in a website’s database queries to
execute arbitrary SQL commands, potentially gaining unauthorized access to data.
3. Denial of Service (DoS): Attackers flood the website with excessive traffic,
overwhelming the server and making the site unavailable to legitimate users.
Question 9:
1. Usability Testing: Evaluates how easy and intuitive the website is for users to navigate
and interact with.
2. Performance Testing: Measures the website’s responsiveness and stability under
various conditions, such as high traffic.
3. Security Testing: Identifies vulnerabilities and ensures the website is protected against
potential threats and attacks.
(b) Write a JavaScript program embedded in HTML that displays all even numbers less
than 20, followed by a horizontal line, and then the sum of the numbers.
Answer:
html
Copy code
<!DOCTYPE html>
<html>
<head>
<title>Even Numbers</title>
</head>
<body>
<script>
let sum = 0;
document.write("Even numbers less than 20:<br>");
for (let i = 0; i < 20; i += 2) {
document.write(i + "<br>");
sum += i;
}
document.write("<hr>");
document.write("Sum: " + sum);
</script>
</body>
</html>
(c) Write an ASP code embedded in HTML that assigns a value "Good" to a variable
TimeOfDay. The program should display "Good Morning" if the value of TimeOfDay is
"Good" and "Good Afternoon" otherwise.
Answer:
html
Copy code
<!DOCTYPE html>
<html>
<head>
<title>ASP Greeting</title>
</head>
<body>
<%
Dim TimeOfDay
TimeOfDay = "Good"
If TimeOfDay = "Good" Then
Response.Write("Good Morning")
Else
Response.Write("Good Afternoon")
End If
%>
</body>
</html>
Question 1:
(ii) Write a JavaScript function that prompts a user to enter a color. The function then
uses the color entered to set the link color within the existing web page.
Answer:
html
Copy code
<!DOCTYPE html>
<html>
<head>
<title>Change Link Color</title>
<style>
a { color: black; }
</style>
</head>
<body>
<a href="#">This is a link</a>
<script>
function changeLinkColor() {
let color = prompt("Enter a color:");
if (color) {
document.querySelector('a').style.color = color;
}
}
changeLinkColor();
</script>
</body>
</html>
Question 5:
(i) Cross-Platform:
Answer: Content that is compatible and functional across different operating systems and
devices without modification.
(ii) Interactive:
Answer: Content that allows user interaction, such as forms, buttons, and other elements that
respond to user input.
(iii) Dynamic:
Answer: Content that changes based on user interactions or real-time data, providing a
customized experience for the user.
(b) Write JavaScript that creates an array to store the values 1 through 5 and prints
elements in the array in reverse order.
Answer:
html
Copy code
<!DOCTYPE html>
<html>
<head>
<title>Reverse Array</title>
</head>
<body>
<script>
let values = [1, 2, 3, 4, 5];
values.reverse(); // Reverse the array
for (let i = 0; i < values.length; i++) {
document.write(values[i] + "<br>");
}
</script>
</body>
</html>
(i) mailto:
Answer: Opens the default email client to compose an email to the specified address.
(ii) gopher:
Answer: An obsolete URL scheme for the Gopher protocol, used for retrieving documents and
data before the advent of the web.
Question 6:
Question 8:
(a) Outline the phases that a web designer should consider during the design of a website.
Answer:
1. Requirement Gathering: Understanding the needs and goals of the website, and
gathering client requirements.
2. Design: Creating wireframes and mockups, defining the visual style, and designing the
user interface.
3. Development: Building the website using appropriate technologies and coding practices.
4. Testing: Checking functionality, compatibility, and performance across different devices
and browsers.
5. Deployment: Launching the website and making it live on the web.
6. Maintenance: Regularly updating the site, fixing issues, and improving functionality
based on user feedback.
1. (a) Explain the function of each of the following protocols in the Internet:
FTP is used to transfer files between a client and a server on a network. It allows users to
upload or download files, manage file directories, and perform other file management
tasks.
NNTP is used for reading and posting articles to newsgroups on a network. It's primarily
used for the distribution, inquiry, retrieval, and posting of news articles.
(iii) Gopher:
Gopher is an older protocol used for distributing, searching, and retrieving documents
over the Internet. It presents information in a menu-driven format.
1. (b) When Amina downloaded a file from the Internet, she noticed that the file had a ZIP
extension.
Downloading refers to the process of transferring data or files from a remote server to a
local device, such as a computer or mobile device.
(ii) Explain why the document had a ZIP extension:
A file with a ZIP extension indicates that it is compressed to reduce its size, making it
easier to download and store. ZIP files can contain one or more files bundled together.
1. (c) Distinguish between an address bar and a status bar as used in a web browser
window:
Address Bar: The address bar in a web browser displays the URL of the webpage
currently being viewed and allows users to enter a web address to navigate to a different
page.
Status Bar: The status bar displays information about the current state of the web page,
such as loading progress or the destination URL when hovering over a hyperlink.
1. (d) Describe three types of files that may be used for images during the development of a
website:
JPEG (Joint Photographic Experts Group): Widely used for photographs and images
with gradients. JPEG files are compressed, balancing image quality and file size.
PNG (Portable Network Graphics): Ideal for images that require transparency and
lossless compression, such as logos or icons.
GIF (Graphics Interchange Format): Commonly used for simple graphics, animations,
and images with limited colors (up to 256 colors).
2. (a) Outline four attributes that may be used with <img> in HTML:
Explain the function of the graphic editor and list four examples of graphic editors:
Function: A graphic editor is used to create and modify digital images, including
drawings, illustrations, and photographs.
Examples:
o Adobe Photoshop
o CorelDRAW
o GIMP (GNU Image Manipulation Program)
o Adobe Illustrator
Web hosting is a service that allows individuals or organizations to make their website
accessible via the World Wide Web by storing their site's files on a server.
(ii) Thumbnail:
Online chat refers to real-time text-based communication over the Internet between two
or more users.
Explain the term broken link as used in a website and outline four reasons that may cause
broken links:
Broken Link: A broken link is a hyperlink that points to a web page or resource that is
no longer available or accessible.
Causes:
o The target page or resource has been deleted.
o The URL of the target page has been changed without updating the link.
o The website hosting the resource has moved to a different domain.
o There are typographical errors in the URL.
(i) View: Allows the user to change the layout, appearance, and visibility of different
elements in the browser window.
(ii) Favorites: A list where users can save and quickly access their preferred or
frequently visited websites.
(iii) Tools: Provides access to various settings and utilities within the browser, such as
history, downloads, extensions, and developer tools.
Distinguish between a portal web page and a news web page as used in the Internet:
Portal Web Page: A portal is a web page that serves as a gateway to a variety of
services, information, and links. It often includes personalized content, search engines,
and other tools.
News Web Page: A news web page focuses on delivering current news stories, articles,
and updates to its audience. It often includes categories for different types of news, such
as politics, sports, and entertainment.
File Transfer Protocol (FTP): A standard network protocol used to transfer files from
one host to another over a TCP-based network, such as the Internet. It allows users to
upload, download, and manage files on a server.
Network News Transfer Protocol (NNTP): A protocol used for the distribution,
inquiry, retrieval, and posting of news articles using a reliable, stream-based transmission
like TCP. It is used to read and post articles (called "news") to newsgroups on a news
server.
Gopher: A distributed document search and retrieval protocol that offers some features
similar to the World Wide Web but is text-based and hierarchical. It was widely used
before the web became popular.
Cookies are small text files that websites place on your computer or device when you visit them.
They are used to store information about your visit, such as your preferences, login status, or the
items in your shopping cart.
1. Session Cookies: These are temporary cookies that are deleted once you close your
browser. They are used to remember your actions during a single browsing session.
2. Persistent Cookies: These cookies remain on your device even after you close your
browser. They are used to remember your preferences or actions for future visits, such as
keeping you logged in to a site.
3. Third-Party Cookies: These are cookies set by a domain other than the one you are
visiting. They are often used for tracking your online behavior across different sites,
typically for advertising purposes.
What is HTML
HTML (HyperText Markup Language) is the standard language used to create and design web
pages. It provides the structure of a webpage by using various elements, tags, and attributes to
format content, such as text, images, links, and multimedia. HTML is the foundation of all web
development and works alongside CSS (Cascading Style Sheets) and JavaScript to create
visually appealing and interactive websites.
Elements and Tags: HTML uses tags, which are enclosed in angle brackets (e.g., <h1>,
<p>, <a>), to define different types of content and how it should be displayed in a
browser.
Attributes: Tags can have attributes that provide additional information about an
element, such as an image's source (<img src="image.jpg">) or a link's destination (<a
href="https://example.com">).
Document Structure: An HTML document typically includes a <!DOCTYPE html>
declaration, followed by <html>, <head>, and <body> tags to structure the content.
1. <head>:
o The <head> tag contains meta-information about the HTML document, such as its
title, character set, styles, and scripts. It's not displayed directly on the webpage
but is essential for defining how the page should be processed and presented.
o Example: It may include <meta>, <title>, <link>, <style>, and <script> tags.
2. <link>:
o The <link> tag defines the relationship between the current document and an
external resource. It's commonly used to link to external stylesheets (CSS) or
prefetch DNS information. It's always placed inside the <head> section.
o Example: <link rel="stylesheet" href="styles.css"> links an external CSS file to
the HTML document.
3. <title>:
o The <title> tag sets the title of the HTML document, which is displayed in the
browser's title bar or tab. It also serves as the title when the page is bookmarked.
The <title> tag is required within the <head> section of the HTML document.
o Example: <title>My Web Page</title> will display "My Web Page" in the
browser's tab.
4. <tr>:
o The <tr> tag is used to define a row in an HTML table. It contains one or more
<td> (table data) or <th> (table header) elements that represent the cells within the
row.
o Example: <tr><td>Row 1, Cell 1</td><td>Row 1, Cell 2</td></tr> creates a row
with two cells in a table.
The <blockquote> tag is used for quoting a block of text from another source,
usually with a citation.
Example:
html
Copy code
<blockquote cite="https://www.example.com">
This is a blockquote from another website.
</blockquote>
html
Copy code
<!DOCTYPE html>
3. Define an abbreviation:
The <abbr> tag is used to define an abbreviation or acronym, providing a full
expansion of the term when hovered over in some browsers.
Example:
html
Copy code
<abbr title="World Health Organization">WHO</abbr>
html
Copy code
<p>This is an <ins>updated</ins> version of the text.</p>
<p>This is the <del>removed</del> text.</p>
With diagram distinguish between character style and logical style as used in html
1. Character Style
Purpose: Character styles in HTML are typically used for physical appearance or
presentation. They directly control how the text looks.
Examples:
<b>: Bold text
<i>: Italic text
<u>: Underlined text
Example Usage:
html
Copy code
<p>This is a <b>bold</b> statement.</p>
<p>This text is <i>italicized</i>.</p>
Diagram: Imagine text displayed with bold and italic properties. These are physical
styles that you can see on the screen.
(Example of Character Style: Bold and Italicized Text)
2. Logical Style
Purpose: Logical styles focus on the meaning of the text rather than how it is displayed.
They describe the role or significance of the content.
Examples:
<em>: Emphasized text (typically rendered in italic, but emphasizes importance)
<strong>: Strongly emphasized text (typically rendered in bold, but signifies
importance)
<cite>: Citation (for titles of works like books or research papers)
Example Usage:
html
Copy code
<p>This word is <em>important</em> for the sentence.</p>
<p>This is a <strong>very important</strong> notice.</p>
Diagram: Logical styles might be rendered similarly to character styles (e.g., <em>
might look like <i>), but they convey semantic meaning to browsers and search engines.
Key Differences
The distinction is essential in HTML, especially for creating accessible and well-structured web
content.
Explain two types of URLs that can be applied in webpage
1. Absolute URL
Definition: An Absolute URL is a full web address that includes all the necessary
information to locate a resource on the internet. It specifies the entire path, starting from
the protocol (such as http:// or https://), followed by the domain name, and ending with
the specific path to a file or resource.
Example: https://www.example.com/folder/page.html
Usage: Absolute URLs are commonly used when linking to resources that are hosted on
different websites or domains.
2. Relative URL
Key Differences
Absolute URLs are used when you want to provide a complete address to a resource,
making sure it is accessible from anywhere.
Relative URLs are more convenient for maintaining links within the same website, as
they make the code easier to manage when the domain changes.
<br>
<input type="submit" value="Submit">
</form>
</body>
</html>
Explanation:
<fieldset> is used to group related elements in a form, with each student having their
own fieldset.
<legend> provides a caption for each group, making it easier to identify which set of
details belongs to which student.
<label> is associated with the input elements to identify the purpose of the input.
<input type="text"> is used for text input (e.g., name and student ID).
<input type="number"> is used for numerical input (e.g., age).
<input type="submit"> creates a submit button to send the form data to the server.
Here’s a list of the top 50 questions and answers commonly asked in CSS and HTML interviews:
HTML Questions
1. What is HTML?
o HTML (HyperText Markup Language) is the standard markup language used to
create web pages.
2. What are HTML tags?
o HTML tags are the building blocks of HTML, used to create elements. They
usually come in pairs: an opening tag and a closing tag.
3. What is the difference between HTML and XHTML?
o HTML is more flexible with syntax, whereas XHTML is stricter, following XML
syntax rules.
4. What are semantic elements in HTML?
o Semantic elements clearly describe their meaning, e.g., <header>, <footer>,
<article>, <section>.
5. What is the purpose of the <DOCTYPE> declaration?
o It defines the document type and version of HTML being used to help browsers
render the page correctly.
6. How do you create a hyperlink in HTML?
o Using the <a> tag with the href attribute: <a href="url">Link Text</a>.
7. What is the difference between inline and block elements?
o Block elements take up the full width available and start on a new line, e.g.,
<div>, while inline elements take up only as much width as necessary and do not
start on a new line, e.g., <span>.
8. What is the <meta> tag used for?
o It provides metadata about the HTML document, such as character set, author,
description, and keywords.
9. How do you embed multimedia in HTML?
o Using tags like <img>, <audio>, <video>, and <iframe> for images, audio,
video, and external content, respectively.
10. What is the purpose of the <form> tag in HTML?
o It is used to create an HTML form for user input, containing elements like text
fields, checkboxes, and buttons.
11. Explain the difference between <div> and <span>.
o <div> is a block-level element used for grouping content, while <span> is an
inline element used to style a specific part of the content.
12. How can you create a table in HTML?
o Using the <table>, <tr>, <th>, and <td> tags for tables, rows, headers, and data
cells, respectively.
13. What is an iframe in HTML?
o An <iframe> is used to embed another HTML document within the current
document.
14. How do you specify comments in HTML?
o Comments are added with <!-- Comment goes here -->.
15. What is the purpose of the <head> tag in HTML?
o It contains metadata, links to CSS files, scripts, and other information not visible
on the webpage.
16. What is the difference between <ol>, <ul>, and <li> tags?
o <ol> creates an ordered list, <ul> creates an unordered list, and <li> represents a
list item.
17. How do you create a form input field in HTML?
o Using the <input> tag with various type attributes like text, password,
checkbox, radio, etc.
18. What is a <canvas> element?
o It is used to draw graphics on the web page via scripting (usually JavaScript).
19. What are HTML attributes?
o Attributes provide additional information about elements, usually as name-value
pairs within the opening tag.
20. What is the difference between id and class attributes?
o id is unique to a single element, while class can be used by multiple elements
for styling or scripting.
21. What are self-closing tags in HTML?
o Tags that do not require a closing tag, e.g., <img />, <br />, <hr />.
22. How do you make a webpage responsive?
o Using the <meta name="viewport" content="width=device-width,
initial-scale=1.0"> tag and media queries in CSS.
23. How can you embed a YouTube video in HTML?
o By using an <iframe> tag with the YouTube video’s URL.
24. What is the <em> tag used for?
o It is used to emphasize text, typically rendering it in italic.
25. Explain the concept of HTML5 local storage.
o Local storage allows data to be stored in the user's browser persistently without
expiration, accessible even after the browser is closed.
CSS Questions