Asignmant
Asignmant
1. nav.html
<!DOCTYPE html>
<html>
<head>
<title>Navigation</title>
</head>
<body style="margin: 0; padding: 0; background-color: #f4f4f4; text-align:
center;">
<a href="index.html" style="color: black; text-decoration: none; margin:
10px;">Home</a> |
<a href="books.html" style="color: black; text-decoration: none; margin:
10px;">Books</a> |
<a href="contact.html" style="color: black; text-decoration: none; margin:
10px;">Contact</a>
</body>
</html>
</body>
</html>
3. books.html (Books Page)
<!DOCTYPE html>
<html>
<head>
<title>Bookstore - Books</title>
</head>
<body style="margin: 0; font-family: Arial, sans-serif;">
</body>
</html>
</body>
</html>
How it Works:
1. Navigation (nav.html): Contains links to Home, Books, and Contact pages. Embedded in all
pages using <iframe>.
2. Home Page (index.html): Welcomes visitors, introduces the bookstore, and provides a link
to the Books page.
3. Books Page (books.html): Lists book categories and includes a link to the Contact page for
further inquiries.
4. Contact Page (contact.html): Displays contact details and invites visitors to reach out.
Each page uses inline styles for a clean and visually appealing layout, while the <iframe> ensures
consistent navigation across all pages.
Here is the implementation of the assignment requirements for your HTML and CSS project:
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Assignment 2: Web Development Basics</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<!-- PART 1: Profile Information Form -->
<section id="profile-form" class="section">
<h1>Profile Information Form</h1>
<form>
<fieldset>
<legend>Personal Information</legend>
<label for="fullname">Full Name:</label>
<input type="text" id="fullname" name="fullname" required><br><br>
<label for="email">Email Address:</label>
<input type="email" id="email" name="email" required><br><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password"
required><br><br>
<label>Gender:</label>
<input type="radio" id="male" name="gender" value="Male" required>
<label for="male">Male</label>
<input type="radio" id="female" name="gender" value="Female">
<label for="female">Female</label>
<input type="radio" id="other" name="gender" value="Other">
<label for="other">Other</label><br><br>
<label>Hobbies:</label>
<input type="checkbox" id="reading" name="hobbies" value="Reading">
<label for="reading">Reading</label>
<input type="checkbox" id="traveling" name="hobbies"
value="Traveling">
<label for="traveling">Traveling</label>
<input type="checkbox" id="music" name="hobbies" value="Music">
<label for="music">Music</label>
<input type="checkbox" id="sports" name="hobbies" value="Sports">
<label for="sports">Sports</label><br><br>
<label for="country">Country:</label>
<select id="country" name="country">
<option value="usa">United States</option>
<option value="uk">United Kingdom</option>
<option value="india">India</option>
<option value="canada">Canada</option>
</select><br><br>
<button type="submit">Submit</button>
<button type="reset">Reset</button>
</fieldset>
</form>
</section>
<!-- PART 2: Data Summary Table -->
<section id="data-summary" class="section">
<h1>Data Summary Table</h1>
<table>
<thead>
<tr>
<th>Field Description</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Full Name</td>
<td>Your Input</td>
</tr>
<tr>
<td>Email Address</td>
<td>Your Input</td>
</tr>
<tr>
<td>Date of Birth</td>
<td>Your Input</td>
</tr>
<tr>
<td>Gender</td>
<td>Your Input</td>
</tr>
<tr>
<td>Hobbies</td>
<td>Your Input</td>
</tr>
<tr>
<td>Country</td>
<td>Your Input</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="2">End of Table</td>
</tr>
</tfoot>
</table>
</section>
styles.css
/* General Styles */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
h1 {
text-align: center;
color: #333;
}
/* Section Styling */
.section {
padding: 20px;
margin: 20px;
border: 1px solid #ddd;
border-radius: 5px;
}
/* Form Styling */
form {
background-color: #f9f9f9;
padding: 20px;
width: 500px;
margin: 0 auto;
border: 1px solid #ccc;
border-radius: 5px;
}
/* Table Styling */
table {
width: 80%;
margin: 0 auto;
border-collapse: collapse;
}
table, th, td {
border: 1px solid #ccc;
padding: 10px;
text-align: left;
}
thead tr {
background-color: #f4f4f4;
}
tbody tr:nth-child(even) {
background-color: #f9f9f9;
}
/* Responsive Layout */
@media (max-width: 768px) {
form {
width: 90%;
}
table {
width: 100%;
}
}
Notes
• Ensure the image webdev.jpg is added to your project folder for the article.
• The CSS makes the layout responsive and visually appealing with hover effects and alternating
table row colors.
• Inline comments in the HTML and CSS guide students through the structure and styling.
Here’s how you can structure and implement your Portfolio Website with the required Converters
using HTML, CSS, and JavaScript. This structure provides a strong foundation, highlights the core
requirements, and includes detailed sections to integrate the converters.
1. File Structure
Organize your project as follows:
portfolio/
├── index.html
├── about.html
├── projects.html
├── converters/
│ ├── currency.html
│ ├── temperature.html
│ ├── unit.html
│ ├── binary.html
│ ├── timezone.html
├── css/
│ ├── styles.css
│ ├── converters.css
├── js/
│ ├── currency.js
│ ├── temperature.js
│ ├── unit.js
│ ├── binary.js
│ ├── timezone.js
├── assets/
│ ├── images/
│ ├── fonts/
├── api/
│ ├── exchange-rates.js
3. Converters Pages
Each converter will be its own webpage. Below are the details for one of the converters—Currency
Converter—and a similar approach can be applied to others.
<label for="fromCurrency">From:</label>
<select id="fromCurrency"></select>
<label for="toCurrency">To:</label>
<select id="toCurrency"></select>
<button id="convert">Convert</button>
<div id="result"></div>
</section>
</main>
</body>
</html>
currency.js
const fromCurrency = document.getElementById("fromCurrency");
const toCurrency = document.getElementById("toCurrency");
const amountInput = document.getElementById("amount");
const resultDiv = document.getElementById("result");
currencies.forEach(currency => {
const option = document.createElement("option");
option.value = currency;
option.textContent = currency;
fromCurrency.appendChild(option.cloneNode(true));
toCurrency.appendChild(option);
});
} catch (error) {
console.error("Failed to fetch currencies", error);
}
}
try {
const response = await fetch(`${apiUrl}${from}`);
const data = await response.json();
const rate = data.rates[to];
const convertedAmount = (amount * rate).toFixed(2);
resultDiv.textContent = `${amount} ${from} = ${convertedAmount} ${to}`;
} catch (error) {
console.error("Conversion failed", error);
}
}
document.getElementById("convert").addEventListener("click", convertCurrency);
window.addEventListener("load", fetchCurrencies);
CSS (converters.css)
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
}
header {
text-align: center;
background-color: #4CAF50;
color: white;
padding: 1rem 0;
}
main {
display: flex;
justify-content: center;
align-items: center;
height: 80vh;
}
#converter {
background: white;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
button {
background-color: #4CAF50;
color: white;
padding: 10px 15px;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
#result {
margin-top: 20px;
font-weight: bold;
}
5. Responsive Design
Use CSS Grid or Flexbox to make all pages responsive. For example:
@media (max-width: 768px) {
main {
flex-direction: column;
padding: 10px;
}
}
This approach ensures each section of the portfolio is interactive, responsive, and well-designed.