Professional Documents
Culture Documents
FST CIA 1 Answers (1)
FST CIA 1 Answers (1)
FST CIA 1 Answers (1)
Question
1 Predict the output for the following program:
2 Write a webpage that will display an image along with reference link:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
</body>
</html>
Mango
Apple
o Green Apple
o Red Apple
o Papaya
<!DOCTYPE html>
<html>
<head>
<title>Fruit List</title>
</head>
<body>
<ul>
<li>Mango</li>
<li>Apple</li>
<li>Papaya</li>
</ul>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<table border="1">
<tr>
<th>Department</th>
<th>Total no of Students</th>
</tr>
<tr>
<td>CSE</td>
<td>120</td>
</tr>
<tr>
<td>MECH</td>
<td>100</td>
</tr>
<tr>
<td>IT</td>
<td>60</td>
</tr>
</table>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Display Text</title>
</head>
<body>
<script>
function displayText() {
document.write("Technologies");
displayText();
</script>
</body>
</html>
An external style sheet in CSS is a separate file containing CSS rules that can be
linked to an HTML document using the <link> element in the HTML's <head>
section. This allows for the separation of content and presentation, simplifies
maintenance, and promotes design consistency across multiple web pages.
<head>
<title>Seminar Schedule</title>
</head>
<body>
<h1>Seminar Schedule</h1>
(Or)
10 b) (i) Design the following web page using HTML:
<!DOCTYPE html>
<html>
<head>
<title>Registration Form</title>
</head>
<body>
<h1>Registration Form</h1>
<form action="#" method="post">
<label for="name">Enter Name</label><br>
<input type="text" id="name" name="name" required><br><br>
<label>Select Game</label><br>
<input type="checkbox" id="hockey" name="game" value="Hockey">
Hockey<br>
<input type="checkbox" id="football" name="game" value="Football">
Football<br>
<input type="checkbox" id="badminton" name="game"
value="Badminton"> Badminton<br>
<input type="checkbox" id="cricket" name="game" value="Cricket">
Cricket<br>
<input type="checkbox" id="volleyball" name="game"
value="Volleyball"> Volleyball<br><br>
<label for="gender">Gender</label><br>
<input type="radio" id="male" name="gender" value="Male">
Male<br>
<input type="radio" id="female" name="gender" value="Female">
Female<br><br>
</html>
(ii) Design a website for Ace car company based on the layout shown in
figure using HTML:
(i) Header.html - the header must contain the name of the company and a
logo at the left.
<!DOCTYPE html>
<html>
<head>
<title>Ace Car Company</title>
</head>
<body>
<header>
<div id="logo">
<img src="logo.png" alt="Ace Car Company Logo">
</div>
<div id="company-name">
Ace Car Company
</div>
</header>
</body>
</html>
(ii) Left Panel - the left panel should contain links to 2 pages
• Contact.html - should contain the address, phone number, fax and email id
of the company.
<head>
<title>Home - Ace Car Company</title>
</head>
<body>
<main>
<h1>Welcome to Ace Car Company</h1>
<p>This is a brief description about our company...</p>
</main>
</body>
</html>
(iii)Footer.html - the footer must contain a copyright information of the
company along with the links to social media websites.
<footer>
<div id="copyright">
© 2023 Ace Car Company
</div>
<div id="social-media">
<a href="#">Facebook</a> |
<a href="#">Twitter</a> |
<a href="#">Instagram</a>
</div>
</footer>
11 a) (i) Design a web page and display the text "Welcome to FS T” with following
specifications.
Color: Navy
Decoration: underline
<!DOCTYPE html>
<html>
<head>
<title>Welcome to FS T^ prime prime</title>
<style>
body {
background-color: yellow;
font-family: Arial, sans-serif;
color: navy;
text-decoration: underline;
}
</style>
</head>
<body>
<h1>Welcome to FS T^ prime prime</h1>
</body>
</html>
(ii).
Design the web page to demonstrate text rollover so that the rollover will
change the link to red and make the underline appear.
<!DOCTYPE html>
<html>
<head>
<title>Text Rollover Demo</title>
<style>
/* Initial link styling */
a{
color: navy;
text-decoration: none;
}
/* Rollover effect */
a:hover {
color: red;
text-decoration: underline;
}
</style>
</head>
<body>
<h1>Text Rollover Demo</h1>
<p>Hover over the link below to see the rollover effect:</p>
<a href="#">Hover Me</a>
</body>
</html>
(Or)
11 b) Design your own web pages using the following CSS properties. 1. opacity 2. flex
3. font-stretch 4. text-decoration-color 5. text-decoration-line 6. text-decoration-
style 7. text-shadow 8. transform 9. word-wrap 10. border-top-left-radius
<!DOCTYPE html>
<html>
<head>
<title>CSS Property Examples</title>
<style>
/* 1. Opacity */
.opacity-example {
opacity: 0.5;
}
/* 2. Flex */
.flex-container {
display: flex;
justify-content: center;
align-items: center;
height: 200px;
background-color: lightblue;
}
.flex-item {
flex: 1;
background-color: lightcoral;
padding: 10px;
}
/* 3. Font Stretch */
.font-stretch-example {
font-stretch: expanded;
}
/* 7. Text Shadow */
.text-shadow-example {
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}
/* 8. Transform */
.transform-example {
transform: rotate(20deg) scale(1.2);
}
/* 9. Word Wrap */
.word-wrap-example {
word-wrap: break-word;
width: 150px;
}
/* 10. Border Top Left Radius */
.border-radius-example {
border-top-left-radius: 20px;
background-color: lightgreen;
padding: 20px;
}
</style>
</head>
<body>
<h1>CSS Property Examples</h1>
<div class="flex-container">
<div class="flex-item">2. Flex</div>
</div>
YELLOW
ORANGE
RED
Answer:
<!DOCTYPE html>
<html>
<head>
<title>CSS Grid Layout</title>
<style>
.grid-container {
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr; /* Four equal-width columns */
grid-gap: 10px; /* Gap between grid items */
background-color: lightgray; /* Background color for the entire grid */
padding: 10px; /* Padding for the entire grid */
}
.green {
background-color: green;
padding: 20px;
}
.yellow {
background-color: yellow;
padding: 20px;
}
.orange {
background-color: orange;
padding: 20px;
}
.red {
background-color: red;
padding: 20px;
}
</style>
</head>
<body>
<div class="grid-container">
<div class="green">GREEN</div>
<div class="yellow">YELLOW</div>
<div class="orange">ORANGE</div>
<div class="red">RED</div>
</div>
</body>
</html>
12 a) (i) Explain how to install reactjs and create function display to display the text
Welcome to ReactJS".
Installation – 4 marks.
Write the code in Display.JS:
import React from 'react';
function Display() {
return (
<div>
<h1>Welcome to ReactJS</h1>
</div>
);
}
export default Display;
Now, you need to render the Display component in the src/App.js file. You
can do this by replacing the content of the return statement in the App
component with <Display />:
function App() {
return (
<div className="App">
<Display />
</div>
);
}
(ii Explain the react component and types in details.
) React components are the building blocks of a React application. They are
JavaScript classes or functions that define the user interface (UI) of your
application. React components encapsulate the logic and presentation of a
part of your application's UI, allowing you to create reusable, modular, and
maintainable code.
There are two main types of React components:
1. Class Components:
Class components are JavaScript classes that extend the
`React.Component` base class. They use the ES6 class syntax and have
lifecycle methods, which allow you to control the behavior of the component
at different stages of its life cycle. Class components are often used for more
complex components that require state management and lifecycle methods.
Here's an example of a simple class component:
import React, { Component } from 'react';
class MyComponent extends Component {
constructor(props) {
super(props);
this.state = {
count: 0,
};
}
handleClick = () => {
this.setState({ count: this.state.count + 1 });
};
render() {
return (
<div>
<h1>{this.props.title}</h1>
<p>Count: {this.state.count}</p>
<button onClick={this.handleClick}>Increment</button>
</div>
);
}
}
export default MyComponent;
2. Functional Components:
Functional components are JavaScript functions that accept props as input
and return JSX (JavaScript XML) as output. They are simpler and more
lightweight than class components and are often used for presentational
components that don't need to manage state or lifecycle methods. With the
introduction of React Hooks, functional components can also manage state
and side effects.
Here's an example of a functional component:
import React, { useState } from 'react';
function MyComponent(props) {
const [count, setCount] = useState(0);
const handleClick = () => {
setCount(count + 1);
};
return (
<div>
<h1>{props.title}</h1>
<p>Count: {count}</p>
<button onClick={handleClick}>Increment</button>
</div>
);
}
export default MyComponent;
Key Concepts:
- Props: Both class and functional components can receive data from their
parent components via props. Props are read-only and help pass data and
configuration to child components.
State: Class components can manage internal state using the `state` object,
while functional components can use the `useState` hook to manage state.
State represents data that can change over time and triggers component re-
rendering when updated.
Lifecycle Methods: Class components have lifecycle methods like
`componentDidMount`, `componentDidUpdate`, and
`componentWillUnmount` that allow you to perform actions at specific
points in the component's life cycle. Functional components can replicate
similar behavior using the `useEffect` hook.
Rendering: All React components must implement the `render` method (for
class components) or return JSX (for functional components). JSX describes
the component's UI and structure.
Component Composition: You can compose complex UIs by nesting
components within each other. This promotes code reuse and
maintainability.
Hooks: React introduced hooks, such as `useState`, `useEffect`,
`useContext`, and others, to allow functional components to manage state
and side effects previously managed by class components.
(Or)
12 b) (i) Explain the following react components to add Styling. i)Add the Global Style
ii)Create a Style for Each Individual component. iii)Adding Inline Style
to React Component.
Styling in React components can be accomplished in various ways to achieve
different levels of control and reusability. Here are explanations for the three
approaches you mentioned:
i) Add the Global Style:
Adding a global style in a React application means applying CSS styles that
affect the entire application. This can be done by importing an external CSS
file into your project or using a CSS-in-JS library like `styled-components`
to create global styles.
- External CSS: You can create a separate CSS file (e.g., `styles.css`) with
global styles and then import it into your React application. Any styles
defined in this file will apply globally to all components.
// In your React component
import './styles.css';
- Styled-components: If you're using a CSS-in-JS library like `styled-
components`, you can create global styles using their `createGlobalStyle`
API.
import { createGlobalStyle } from 'styled-components';
const GlobalStyle = createGlobalStyle`
body {
background-color: #f0f0f0;
font-family: Arial, sans-serif;
}
`;
// In your React component
<div>
<GlobalStyle />
{/* ... rest of your component */}
</div>
ii) Create a Style for Each Individual Component:
To create styles for individual components, you can use CSS modules,
styled-components, or any other CSS-in-JS solution. This approach keeps
styles isolated to specific components, promoting modularity and reusability.
- CSS Modules: When using CSS modules, you create a separate CSS file for
each component and import the styles directly into the component file.
// MyComponent.js
import React from 'react';
import styles from './MyComponent.module.css';
function MyComponent() {
return <div className={styles.container}>Styled Component</div>;
}
export default MyComponent;
css
/* MyComponent.module.css */
.container {
background-color: #ff0000;
color: #ffffff;
}
Styled-components: With `styled-components`, you can define styles
directly within your component file, creating a styled component that
encapsulates its styles.
import styled from 'styled-components';
const Container = styled.div`
background-color: #ff0000;
color: #ffffff;
`;
function MyComponent() {
return <Container>Styled Component</Container>;
}
iii) Adding Inline Style to React Component:
Inline styles are applied directly to individual HTML elements within a
component. This approach allows you to define styles using JavaScript
objects.
function MyComponent() {
const divStyle = {
backgroundColor: '#ff0000',
color: '#ffffff',
};
return <div style={divStyle}>Inline Styled Component</div>;
}
In this approach, styles are applied directly to the component's HTML
elements as inline CSS properties. It's useful for applying dynamic styles
based on component state or props.
Each of these styling methods in React provides a different level of control
and flexibility. You can choose the one that best suits your project's
requirements and development style.