Manual Web Engineering
Manual Web Engineering
By the end of this lesson, students will understand what HTML is, its purpose, and the basic
structure of an HTML document. They will learn how to create basic elements like headings,
paragraphs, lists, and links.
Session Breakdown:
What is HTML?
● HTML stands for HyperText Markup Language. It's the standard language used to
create web pages.
● HTML is used to structure content on the web by using various tags to define different
parts of a webpage.
● Every HTML document starts with a <!DOCTYPE html> declaration to tell the browser
what type of document it is.
● The main components of an HTML document are:
1. <html>: The root element that wraps all the content on the page.
2. <head>: Contains metadata about the document, like the title, links to
stylesheets, etc.
3. <body>: Contains the content that is displayed on the page.
Explanation:
Hands-On Task:
Paragraphs:
● Paragraphs are created using the <p> tag. This is used for regular text content
Lists:
● HTML provides two types of lists: unordered lists (<ul>) and ordered lists (<ol>).
● List items are wrapped inside <li> tags.
Links:
● Links are created using the <a> (anchor) tag. The href attribute defines the destination
of the link.
Hands-On Task:
● Inline elements appear inside other elements without breaking the flow of the document
(e.g., within paragraphs).
By the end of Day 2, students will have a clear understanding of how to create a structured
HTML page using semantic HTML elements like <header>, <nav>, <main>, <section>,
and <footer>. They will also understand the importance of semantics in HTML for accessibility
and SEO purposes.
● Semantic HTML introduces meaning to the web content. Instead of using generic tags
like <div>, semantic elements describe the content in a meaningful way.
● Examples of semantic elements include:
○ <header>: Represents the header of the page or section.
○ <nav>: Defines a navigation section.
○ <main>: Represents the main content of the page.
○ <section>: A standalone section of related content.
○ <footer>: Represents the footer of the page or section.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Webpage</title>
</head>
<body>
<header>
<h1>Welcome to My Website</h1>
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
</header>
<main>
<section>
<h2>Main Section</h2>
<p>This is the main content of the webpage.</p>
</section>
</main>
<footer>
<p>© 2024 My Webpage</p>
</footer>
</body>
</html>
Hands-On Task:
● Task: Create the full structure of the landing page using semantic HTML elements.
Steps:
1. Header Section:
○ Create a <header> element that contains a website title and navigation
menu.
○ Inside the <nav>, add a list of links (<ul>) pointing to different sections of
the page.
2. Main Content:
○ Use a <main> element for the primary content.
○Inside <main>, use <section> tags to divide the content logically (e.g., a
product section, service section, etc.).
3. Footer Section:
○ Add a <footer> element that includes some footer information (e.g.,
copyright).
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ShopMaster</title>
</head>
<body>
<header>
<h1>ShopMaster</h1>
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#products">Products</a></li>
<li><a href="#about">About Us</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
</header>
<main>
<section id="home">
<h2>Welcome to ShopMaster</h2>
<p>Your one-stop shop for the best products!</p>
</section>
<section id="products">
<h2>Our Products</h2>
<p>Check out our latest products below.</p>
</section>
</main>
<footer>
<p>© 2024 ShopMaster</p>
</footer>
</body>
</html>
● Links (<a> elements) can link to different sections within the same page using the
id attribute.
● For example, clicking "About Us" in the navigation should scroll the user to the
"About Us" section.
Hands-On Task:
● Task: Create an additional page for "About Us" and link it to the main webpage.
● Steps:
1. Create a new file called about.html.
2. Add a simple structure with a header, main section, and footer.
3. Link the "About Us" navigation item in the main webpage to this new page.
<nav>
<ul>
<li><a href="about.html">About Us</a></li>
</ul>
</nav>
About Page (about.html)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>About ShopMaster</title>
</head>
<body>
<header>
<h1>About ShopMaster</h1>
</header>
<main>
<section>
<h2>Who We Are</h2>
<p>ShopMaster is an online platform that brings you the best products from around
the world.</p>
</section>
</main>
<footer>
<p>© 2024 ShopMaster</p>
</footer>
</body>
</html>
Task:
By the end of Day 3, students will have a solid understanding of how to create and structure
forms in HTML. They will learn to create input fields, buttons, and how to gather user data with
forms.
What is a Form?
Form Structure
Explanation:
● The action attribute specifies the server endpoint where form data will be submitted.
● The method attribute defines how the data is sent (POST is commonly used for form
submissions).
● The <label> tags provide labels for the input fields, and the for attribute connects the
label with the input’s id.
● The <input> fields collect user data, and the <button> submits the form.
Input Types:
● HTML offers a variety of input types that allow users to enter different types of data.
These include text, email, password, checkbox, radio, date, and many more.
● The most common input types include:
○ text: A single line of text.
○ password: Masks the input for passwords.
○ email: Validates that an email format is entered.
○ radio: Select one option from a set of options.
○ checkbox: Allows multiple selections.
<form>
<label for="username">Username:</label>
<input type="text" id="username" name="username">
<br>
<label for="password">Password:</label>
<input type="password" id="password" name="password">
<br>
<label for="email">Email:</label>
<input type="email" id="email" name="email">
<br>
<label for="gender">Gender:</label>
<input type="radio" id="male" name="gender" value="male">
<label for="male">Male</label>
<input type="radio" id="female" name="gender" value="female">
<label for="female">Female</label>
<br>
<button type="submit">Register</button>
</form>
Explanation:
Hands-On Task:
● Labels are essential for accessibility, as they help users (especially those using screen
readers) understand what input is required.
● The placeholder attribute shows a hint inside the input box before the user types.
Explanation:
● Placeholder Text: A short hint that appears in the input field until the user starts typing.
● Textareas: Used for multi-line input, typically for a comment or bio.
● The <fieldset> tag groups related fields within a form, while <legend> provides a
caption for the grouped fields.
Code Example 4: Grouping Form Elements with Fieldset
Explanation:
● Fieldset: Used to group related form elements, making the form more structured and
easier to understand.
● Legend: Provides a title or description for the grouped fields.
Hands-On Task:
● Task: Expand the registration form from the previous task by grouping the fields inside
<fieldset> and using <legend> for the form title.
● A search bar is an input field that allows users to search for specific content on the site.
The form can be sent via the GET method to process the search.
Explanation:
● The action attribute is set to /search, indicating that the form will be submitted to the
search endpoint.
● The form method is GET, which is commonly used for search forms because the data is
appended to the URL.
Task:
By the end of Day 4, students will understand how to group and structure content using <div>
elements and how to organize data in tables. They will learn to nest elements within each other
and use tables for data presentation.
What is a <div>?
● The <div> tag is a block-level container used to group HTML elements together.
● It is often used to apply styles or organize content in sections.
Explanation:
● The <div> tag allows you to group elements together into one section. It does not have
a visual appearance but can be styled with CSS.
● Commonly used for layout and structure.
Hands-On Task:
What is Nesting?
● Nesting means placing one HTML element inside another. This is how most complex
HTML structures are built.
Explanation:
● In this example, an unordered list is nested inside a <div>. The list is further nested
inside the category <h2> heading.
● Nesting helps create a clear hierarchy and structure for the content
Hands-On Task:
● Task: Add a section to your webpage that includes a heading, a paragraph, and a list.
Nest the elements inside a <div>.
● Steps:
1. Create a section called "Product Categories".
2. Inside the <div>, add a heading for the section and an unordered list of
products.
What is a Table?
Hands-On Task:
● The <caption> tag adds a title to the table, which is typically placed above the table.
● <th> is used for table headings, which make the table easier to read and understand.
● You can merge table cells using the colspan and rowspan attributes. colspan
merges columns, and rowspan merges rows.
Explanation:
Task:
● Create a product price table that includes at least three columns: "Product", "Price",
and "Quantity".
● Add a caption for the table.
● Use colspan and rowspan to merge cells where appropriate (e.g., merge product
details like price and warranty into one row).
Day 5: Applying What We've Learned to the Project
Objective:
By the end of Day 5, students will apply the HTML concepts they’ve learned throughout the
week to begin building the structure of the ShopMaster landing page, using semantic HTML,
forms, tables, and grouped elements.
● Recap the key HTML concepts learned during the week, ensuring students have a solid
understanding of:
1. The basic structure of an HTML document.
2. Semantic HTML elements: <header>, <main>, <footer>, <section>, etc.
3. Forms and form elements.
4. Grouping content with <div>.
5. Creating and structuring tables.
Interactive Review:
Hands-On Task:
● Task: Build the header and navigation bar for the ShopMaster landing page using
semantic HTML.
Steps:
1. Inside the <header>, create the main title of the website using an <h1> tag.
2. Inside the <nav>, add a navigation bar with links for "Home", "Products", "About Us",
and "Contact".
3. Group the navigation links using an unordered list (<ul>), with each link inside a list item
(<li>).
Explanation:
● The <header> contains the main title of the page, which is important for accessibility.
● The <nav> wraps around the navigation links, and each link is placed in a list item
(<li>).
● Ensure that links use meaningful text and point to the correct sections or pages.
Hands-On Task:
● Task: Create the hero section of the ShopMaster landing page with a welcome
message and call-to-action (CTA) button.
Steps:
Hands-On Task:
● Task: Add a product section that introduces the list of available products.
Steps:
1. Create another <section> with the id="products" to represent the product section.
2. Add a table to display product names, prices, and available quantities.
Explanation:
● The product section introduces a simple table to display the available products.
● The table contains a header row (<th>) and two product rows (<tr>), each with a
product name, price, and quantity.
Task:
● Expand the landing page by adding more sections or pages based on what students
have learned. Suggested additions include:
○ A form in the "Contact" section where users can submit their name, email, and a
message.
○ A footer with contact details and links to social media.
Code Example 4: Contact Form and Footer
<section id="contact">
<h2>Contact Us</h2>
<form action="/submit" method="POST">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<br>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<br>
<label for="message">Message:</label>
<textarea id="message" name="message"></textarea>
<br>
<button type="submit">Send</button>
</form>
</section>
<footer>
<p>© 2024 ShopMaster</p>
<p>Follow us on <a href="#">Twitter</a>, <a href="#">Facebook</a></p>
</footer>
Explanation:
Recap:
● Review what has been built so far, emphasizing how the concepts from the entire week
come together in the landing page project.
● Answer any final questions.
● By the end of Day 5, students will have applied the HTML concepts they’ve learned
throughout the week to build the basic structure of the ShopMaster landing page,
including the header, navigation, hero section, product list, contact form, and footer.
Week 2: CSS Basics and Layouts
Day 1: Introduction to CSS – Syntax, Selectors, and Basic
Styling
Objective:
By the end of this session, students will understand the basics of CSS syntax, how to link CSS
to HTML, and how to apply basic styling using selectors. They will learn to style text,
backgrounds, and create simple layouts.
What is CSS?
● CSS stands for Cascading Style Sheets. It’s used to control the appearance and layout
of web pages.
● CSS works by targeting HTML elements and applying styles like colors, fonts, margins,
and more.
Explanation:
External CSS: Link to an external stylesheet using the <link> tag inside the <head>.
● Example:
Hands-On Task:
1. Element Selector: Targets all elements of a specific type (e.g., all <p> tags).
○ Example: p { color: red; }
2. Class Selector: Targets elements with a specific class. The class selector is written with
a dot (.).
○ Example: .highlight { background-color: yellow; }
3. ID Selector: Targets a specific element with an ID. The ID selector is written with a hash
(#).
○ Example: #main-title { font-size: 24px; }
4. Universal Selector: Targets all elements on the page (*).
○ Example: * { margin: 0; padding: 0; }
5. Grouping Selectors: Apply the same styles to multiple selectors by separating them
with a comma.
○ Example: h1, h2, p { color: black; }
Hands-On Task:
● Task: Add a class and an ID to your HTML elements and apply CSS styles to them.
● Steps:
1. Create a class called .highlight to change the background color of important
text.
2. Use an ID selector to style the main title.
Typography in CSS:
● Font family: Sets the font for text. You can use system fonts or import custom fonts (like
Google Fonts).
● Font size: Defines the size of the text (e.g., 16px, 1.5em).
● Font weight: Sets the thickness of the font (e.g., bold, normal, 100).
● Text align: Controls the alignment of text (e.g., left, right, center).
● Text color: Changes the text color using names, HEX, RGB, or HSL values.
Hands-On Task:
Backgrounds:
Borders:
● The border property defines a border around an element. You can specify border
width, style, and color.
Hands-On Task:
● Task: Add background colors and borders to different sections of your page.
● Steps:
1. Add a background color to the <body> tag.
2. Apply a border and padding to your paragraphs.
Recap:
Final Task:
● Have students review their webpage, ensuring that all styles are applied correctly
● Every HTML element is represented as a rectangular box, which consists of four areas:
1. Content: The innermost part where the text or images appear.
2. Padding: Space between the content and the border.
3. Border: The edge surrounding the padding (and content).
4. Margin: Space outside the border, separating the element from others.
● Draw a visual on the board or show an image to represent how the content, padding,
border, and margin relate to one another.
Day 2: Box Model, Margins, Padding, and Borders
Objective:
By the end of this session, students will understand how the CSS box model works, including
margins, padding, and borders. They will learn to control the spacing around and inside
elements, and how to use the box model to structure layouts.
● Every HTML element is represented as a rectangular box, which consists of four areas:
1. Content: The innermost part where the text or images appear.
2. Padding: Space between the content and the border.
3. Border: The edge surrounding the padding (and content).
4. Margin: Space outside the border, separating the element from others.
● Draw a visual on the board or show an image to represent how the content, padding,
border, and margin relate to one another.
Explanation:
● The width is 200px, but the total size of the box includes padding, border, and margin.
○ Total width: 200px (width) + 20px (padding) + 5px (border) = 230px.
○ The element will also have an additional 10px of margin outside of it.
Hands-On Task:
● Task: Create a simple box element in HTML and apply the box model properties to it.
● Steps:
1. Create a <div> with the class box in your HTML file.
2. Style the .box in CSS with specific width, padding, border, and margin values.
Padding:
● Padding adds space inside the element, between the content and the border.
● You can control padding for each side individually or set the same padding for all sides.
Explanation:
Margins:
● Margins create space outside the element, pushing it away from other elements.
● Similar to padding, you can control margins for each side individually or set the same
margin for all sides.
Explanation:
Hands-On Task:
● Task: Apply different margin and padding values to various elements on your webpage.
● Steps:
1. Add padding to your headings and paragraphs.
2. Add margins to your images or <div> elements.
Borders:
● Borders are applied around the padding and content. You can control the width, style,
and color of borders.
● Border styles include:
○ solid: A solid line.
○ dashed: A dashed line.
○ dotted: A dotted line.
Explanation:
● Borders add a visual edge around an element. You can control how thick and what style
the border is.
Border Radius:
Explanation:
● A border-radius of 10px creates rounded corners. If you set the radius to 50%, it will
create a circular shape.
Hands-On Task:
● Task: Add borders to your <div>, <p>, or image elements and experiment with different
border styles and border-radius values.
● Steps:
1. Add a border to your product section.
2. Round the corners of your buttons or images using border-radius.
● The width and height properties define the size of an element's content area,
excluding padding, border, and margin.
● You can set width and height using pixels (px), percentages (%), or other units.
Explanation:
● In this example, the content area of the <div> will be 300px wide and 200px high, but
the total size will include padding, borders, and margins.
Box Sizing:
● By default, the width and height only apply to the content area. However, you can
change this behavior using box-sizing: border-box;.
● With border-box, padding and borders are included in the element's total width and
height.
Explanation:
● box-sizing: border-box; makes sure the total width is 300px, including padding
and border, rather than adding padding and border to the width.
Hands-On Task:
Steps:
By the end of this session, students will understand the basics of Flexbox, a powerful CSS
layout tool used to create responsive and flexible layouts. They will learn how to use Flexbox
properties to align, distribute, and order elements on a webpage.
What is Flexbox?
● Flexbox (Flexible Box Layout) is a CSS layout model that allows you to arrange
elements in rows or columns, distribute space, and align items.
● It simplifies creating flexible, responsive designs compared to using floats or manually
setting margins.
● To use Flexbox, you need to set a container's display property to flex, making the
container a flex container, and its direct children become flex items.
● Main Axis: The primary axis along which the flex items are laid out (can be horizontal or
vertical).
● Cross Axis: The axis perpendicular to the main axis.
Explanation:
Hands-On Task:
1. flex-direction:
○ Specifies the direction of the flex items (row or column).
○ Values: row (default), column, row-reverse, column-reverse.
2. justify-content:
○ Aligns flex items along the main axis (horizontally by default).
○ Values: flex-start (default), center, flex-end, space-between,
space-around.
3. align-items:
○ Aligns flex items along the cross axis (vertically by default).
○ Values: stretch (default), center, flex-start, flex-end.
4. flex-wrap:
○ Allows flex items to wrap onto multiple lines.
○ Values: nowrap (default), wrap, wrap-reverse.
Explanation:
Hands-On Task:
● Task: Modify your flex container to experiment with different Flexbox properties
(justify-content, align-items, and flex-direction).
● Steps:
1. Try using justify-content: center;, align-items: flex-start;, and
flex-direction: column; to see how the layout changes.
1. flex-grow:
○ Controls how much the flex item grows relative to the others.
○ Values: Any number (default is 0, meaning no growth).
2. flex-shrink:
○ Controls how much the flex item shrinks relative to the others.
○ Values: Any number (default is 1, meaning items shrink as needed).
3. flex-basis:
○ Defines the default size of the flex item before any growing or shrinking.
○ Values: Can be a length (e.g., 100px) or percentage.
4. order:
○ Specifies the order of the flex items. Lower numbers appear first.
○ Values: Any number (default is 0).
Explanation:
● flex-grow: 2; makes the item grow twice as fast as other items with flex-grow:
1.
● flex-basis: 100px; sets the initial size of the item to 100px before applying growth
or shrink.
Hands-On Task:
● Task: Apply flex-grow, flex-shrink, and flex-basis to your flex items to experiment with
how they grow and shrink within the container.
● Steps:
1. Apply flex-grow: 2; to one item and flex-grow: 1; to others.
2. Experiment with flex-shrink and flex-basis.
● Flexbox simplifies building responsive layouts that adjust to different screen sizes.
● By using Flexbox and media queries, you can change the layout for smaller devices.
Explanation:
● flex-wrap: wrap; allows the items to wrap onto the next line if there's not enough
space.
● The media query adjusts the layout on small screens (e.g., smartphones), setting
flex-basis: 100%; to make each item take up the full width.
Hands-On Task:
Steps:
1. Create a navigation bar with links for "Home", "Products", "About", and "Contact".
2. Use display: flex; to align the links in a row.
3. Add a media query to stack the links vertically on smaller screens.
/* Navigation bar */
nav {
display: flex;
justify-content: space-around;
background-color: #333;
padding: 10px;
}
nav a {
color: white;
text-decoration: none;
padding: 10px;
}
nav a {
text-align: center;
padding: 15px;
}
}
Explanation:
By the end of this session, students will understand advanced Flexbox techniques, including
nested Flexbox layouts and combining Flexbox with media queries for complex responsive
designs. They will apply these techniques to create a more complex, fully responsive layout.
● A nested Flexbox layout refers to placing a flex container inside another flex container.
This is useful for creating complex layouts where different sections of the page need
separate alignments or arrangements.
Hands-On Task:
● Task: Build a nested Flexbox layout with two main sections: a left and a right section.
Each section should contain vertically aligned items.
● Steps:
1. Create a Flexbox container for the entire layout.
2. Nest two flex containers inside it, one for each section (left and right).
3. Arrange the items in each section using flex-direction: column;.
● While align-items applies to all flex items within a container, align-self allows you
to align individual items differently from the others.
Code Example 2: Using align-selfCode Example 2: Using align-self
Explanation:
● align-self: flex-end; moves the first item to the bottom of the container, while
align-self: center; centers the second item vertically.
Hands-On Task:
● Task: Create a Flexbox container with three items, each aligned differently using
align-self.
● Steps:
1. Set up a flex container and add three flex items.
2. Use align-self to align one item to the top, one to the center, and one to the
bottom.
● Flexbox makes it easy to create responsive layouts that adapt to different screen sizes.
By combining Flexbox with media queries, we can adjust the layout based on the
screen width.
● This is important for creating layouts that work well on both desktops and mobile
devices.
● On larger screens, the .item elements take up 30% of the container’s width.
● For screens smaller than 768px (e.g., tablets or mobile devices), the media query
applies, making each .item take up 100% of the container width (stacking the items
vertically).
Hands-On Task:
● Task: Create a responsive product grid using Flexbox and media queries. The grid
should display multiple items side by side on larger screens and stack the items
vertically on smaller screens.
● Steps:
1. Set up a Flexbox container with multiple items.
2. Use flex-basis to arrange the items side by side on large screens.
3. Add a media query to make the items stack on small screens (e.g.,
smartphones).
Task: Build a simple portfolio layout using Flexbox. The portfolio will feature three
sections:
Steps:
1. Profile Section:
○ Create a flex container with an image and bio aligned next to each other.
○ Use align-items: center; to vertically center the content.
2. Skills Section:
○ Use Flexbox to display skill tags in a row. Wrap the items using flex-wrap:
wrap;.
3. Projects Section:
○ Create a responsive grid of project cards. Use flex-basis to control the card
size on large screens and a media query to stack them on smaller screens.
<div class="portfolio-container">
<!-- Profile Section -->
<div class="profile-section">
<img src="profile.jpg" alt="Profile Picture" width="150px">
<div class="bio">
<h2>John Doe</h2>
<p>Web Developer with a passion for creating beautiful and responsive
websites.</p>
</div>
</div>
/* Portfolio container */
.portfolio-container {
display: flex;
flex-direction: column;
padding: 20px;
}
/* Profile section */
.profile-section {
display: flex;
align-items: center;
margin-bottom: 30px;
}
.bio {
margin-left: 20px;
}
.bio h2 {
font-size: 24px;
margin-bottom: 10px;
}
/* Skills section */
.skills-section {
display: flex;
flex-wrap: wrap;
gap: 10px;
margin-bottom: 30px;
}
.skill {
background-color: #3498db;
color: white;
padding: 10px 15px;
border-radius: 5px;
}
/* Projects section */
.projects-section {
display: flex;
flex-wrap: wrap;
gap: 20px;
}
.project-card {
flex-basis: 30%;
background-color: #f4f4f4;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
/* Responsive design */
@media (max-width: 768px) {
.projects-section {
flex-direction: column;
}
.project-card {
flex-basis: 100%;
}
}
Explanation:
1. Profile Section:
○ The profile section uses flex-direction: row; and align-items:
center; to align the image and bio next to each other and center them
vertically.
2. Skills Section:
○ The skill tags are displayed in a row using Flexbox with flex-wrap:
wrap; so that they wrap onto the next line if there are too many to fit in one
row.
3. Projects Section:
○ Each project card is given a flex-basis of 30%, so three cards can fit side
by side on large screens.
○ A media query is added to make the cards stack vertically on smaller
screens, adjusting flex-basis to 100%.
Hands-On Task:
Task: Combine everything you’ve learned in Week 2 to create a fully responsive web
page. The page should include:
By the end of this session, students will apply everything they’ve learned in the past week
(especially Flexbox and responsive design) to create a responsive product grid for the
ShopMaster landing page. This will be their first major step towards completing the full project
by the end of the course.
● Briefly review Flexbox properties, media queries, and responsive design techniques
covered earlier in the week.
● Ensure students are comfortable with using Flexbox for creating layouts and media
queries for responsive design.
Project Focus:
● The main task of the day is to create the responsive product grid section for the
ShopMaster website. This will feature multiple products arranged in a flexible grid that
adjusts depending on screen size.
Task: Create a product grid section on the ShopMaster page where products are displayed in a
grid layout using Flexbox.
Steps:
/* Product Grid */
.product-grid {
display: flex;
flex-wrap: wrap;
gap: 20px;
justify-content: space-between;
padding: 20px;
}
/* Product Card */
.product-card {
flex-basis: 30%;
background-color: #f4f4f4;
padding: 15px;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
text-align: center;
}
.product-card img {
max-width: 100%;
height: auto;
border-radius: 5px;
}
.product-card h3 {
margin: 15px 0 10px;
font-size: 18px;
}
.product-card p {
color: #888;
margin-bottom: 15px;
}
.product-card button {
background-color: #3498db;
color: white;
border: none;
padding: 10px 15px;
border-radius: 5px;
cursor: pointer;
}
.product-card button:hover {
background-color: #2980b9;
}
Task: Apply media queries to make the product grid responsive. On smaller screens (like tablets
and mobile), the grid should adjust to display fewer items per row or stack items vertically.
Steps:
Task: Add interactive hover effects to the product cards to enhance the user experience.
Steps:
Hands-On Task:
● Task: Apply hover effects to your product grid. Add animations or transitions for smooth
interactions.
● Steps:
1. Add hover effects to the product card container (e.g., change the box shadow).
2. Apply hover effects to the “Add to Cart” button.
Task: Use JavaScript (if time permits) to add product data dynamically from an array of objects.
This allows you to practice integrating JavaScript with your layout.
Steps:
<section id="product-grid"></section>
<script>
const products = [
{ name: 'Product 1', price: '$19.99', image: 'product1.jpg' },
{ name: 'Product 2', price: '$29.99', image: 'product2.jpg' }
];
products.forEach(product => {
const productCard = `
<div class="product-card">
<img src="${product.image}" alt="${product.name}">
<h3>${product.name}</h3>
<p>${product.price}</p>
<button>Add to Cart</button>
</div>
`;
productGrid.innerHTML += productCard;
});
</script>
Week 3: Advanced CSS Techniques
CSS Transitions allow changes in CSS property values to occur over a specified duration rather
than happening instantly. This makes visual changes smoother and more appealing.
Transition Properties:
1. transition-property:
○ Defines the specific CSS properties that will change smoothly (e.g.,
background-color, transform, width, opacity).
○ If multiple properties need transitions, they can be listed, separated by commas.
○ Default: all (all properties will transition).
2. Transition-duration:
● Specifies how long the transition should take to complete (e.g., 0.5s for 500
milliseconds).
● If different properties have different durations, they can be listed in the same
order as transition-property.
3. transition-timing-function:
● Defines how the intermediate states of the transition are calculated. Common values are:
○ ease: Start slow, speed up, then slow down (default).
○ linear: Constant speed from start to end.
○ ease-in: Start slow, then speed up.
○ ease-out: Start fast, then slow down.
○ ease-in-out: Slow at both the start and end.
○ Cubic-bezier functions: Custom timing functions like cubic-bezier(0.25,
0.1, 0.25, 1).
4. transition-delay:
● Sets a delay before the transition starts (e.g., 1s will wait 1 second before starting the
transition).
Hover Effects and Pseudo-Classes (45 minutes)
● The :hover pseudo-class applies styles when the user hovers over an element (e.g.,
buttons, links, product cards). It's widely used for interactive effects.
● It can be applied to any element, not just links.
● Hover on Buttons:
○ Change background color, add shadows, scale up the size, or change the text
color on hover.
● Hover on Links:
○ Change the color or underline the text.
● A hover menu is a hidden element that becomes visible only when its parent (e.g., a
product card) is hovered. Common uses include quick view, add to wishlist, and
compare buttons on product cards.
CSS Example:
.product-menu {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: rgba(255, 255, 255, 0.8);
display: flex;
justify-content: center;
align-items: center;
opacity: 0;
visibility: hidden;
transition: opacity 0.3s ease, visibility 0.3s ease;
}
.product-card:hover .product-menu {
opacity: 1;
visibility: visible;
}
3. Adding Menu Buttons:
● Use basic buttons for quick view, add to wishlist, and compare options.
Hands-On Task:
● Implement hover menus that contain Quick View, Add to Wishlist, and Compare
buttons.
● Ensure smooth transitions so the menu fades in when the product card is hovered.
● Students will apply CSS transitions to buttons, links, and product cards to create smooth
hover effects (e.g., changing background color, scaling, and adding shadows).
● Students will implement hover menus on product cards. The menu should contain Quick
View, Add to Wishlist, and Compare buttons that appear smoothly when the product
card is hovered.
CSS animations allow the values of CSS properties to change smoothly over time, using
keyframes. Unlike transitions, which define changes between two states (e.g., normal and
hover), animations can define multiple stages and apply more complex effects.
1. @keyframes:
○ @keyframes defines the stages of the animation.
○ Each keyframe represents a percentage of the animation duration (0% is the
start, 100% is the end).
2. Animation-name:
○ Specifies the name of the @keyframes animation to apply to an element.
3. Animation-duration:
● Specifies how long the animation will take to complete (e.g., 1s for 1 second).
4. Animation-iteration-count:
● Defines how many times the animation will play (e.g., 1, infinite, or any
specific number).
5. animation-timing-function:
● Specifies the speed curve of the animation (similar to
transition-timing-function).
● Common values are ease, linear, ease-in, ease-out, and ease-in-out.
6. Animation-delay:
● Sets a delay before the animation starts.
7. Animation-fill-mode:
● Defines what styles should apply to the element before and after the animation.
Common values:
○ forwards: Retains the final state of the animation.
○ backwards: Applies the starting styles during the delay period.
○ both: Combines both behaviors.
@keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
h1 {
animation-name: fadeIn;
animation-duration: 2s;
}
@keyframes bounce {
0%, 100% {
transform: translateY(0);
}
50% {
transform: translateY(-15px);
}
}
button {
animation-name: bounce;
animation-duration: 1.5s;
animation-iteration-count: infinite;
}
3. Slide-in Animation for Banners:
● Create a slide-in effect for banners to make the page more dynamic.
● Example:
@keyframes slideIn {
0% {
transform: translateX(-100%);
}
100% {
transform: translateX(0);
}
}
.banner {
animation-name: slideIn;
animation-duration: 1s;
}
Smooth scrolling allows for a more fluid user experience when navigating between sections on a
page, especially with anchor links (<a href="#section">). Instead of an instant jump, the
page scrolls smoothly to the target section.
● You can achieve smooth scrolling with a single CSS property: scroll-behavior:
smooth.
● This property can be applied to the html or body element to make all anchor link clicks
scroll smoothly.
● Smooth scrolling is often applied to internal links within a page (e.g., "Back to Top"
button or navigational links).
● Example of an internal anchor link:
Hands-On Task:
● Apply smooth scrolling to the landing page by adding anchor links and applying
scroll-behavior: smooth in the CSS.
● Add a “Back to Top” button that scrolls smoothly to the top of the page.
● Students will create a simple keyframe animation for an element on the landing page.
This can include:
○ A fade-in effect for headers.
○ A bounce effect for buttons.
○ A slide-in animation for a promotional banner.
● Students will implement smooth scrolling for anchor links on the landing page.
● They will add a “Back to Top” button and ensure that it scrolls the page smoothly.
Day 3: Responsive Design with Media Queries
● Media Queries are a feature of CSS that allows the application of different styles based
on the properties of the user’s device, such as screen width, height, orientation, and
resolution.
● Media queries are most commonly used to make websites responsive, adjusting layout
and design elements based on the viewport size.
● Media queries can target specific breakpoints (e.g., mobile, tablet, desktop).
● Min-width applies the styles to screen sizes greater than or equal to the specified
width.
● Max-width applies the styles to screen sizes less than or equal to the specified width.
Common Breakpoints:
● Students will implement media queries to adjust the product grid and header layout for
mobile, tablet, and desktop views.
● Task: Ensure that the product grid switches between single-column on mobile,
two-column on tablets, and four-column on desktops. The header should be stacked
vertically on mobile devices and displayed horizontally on desktops.
● The mobile-first approach means designing the website layout and styles for mobile
devices first, and then scaling up the design for larger screens. This approach ensures
that the website is optimized for smaller screens, where space is limited, and
progressively enhances the design for larger screens.
● Why is this important?:
○ Mobile traffic now represents the majority of website visits, making it essential to
prioritize mobile usability.
○ It helps with performance optimization, ensuring that mobile users receive a
faster experience.
● Chrome DevTools and other browsers provide a powerful device simulation feature to
test websites across multiple screen sizes without needing physical devices.
● Students will learn how to:
○ Open DevTools (right-click -> Inspect or press Ctrl + Shift + I).
○ Click on the Toggle Device Toolbar button (Ctrl + Shift + M) to simulate different
devices.
○ Select from a list of common devices (iPhone, iPad, etc.) or enter custom screen
sizes to test the responsiveness of their design.
● Students will use browser DevTools to test the responsiveness of their landing page.
● They will ensure that the product grid, header, and other elements adapt correctly
across different screen sizes.
Final Task:
Stretch Task:
● For advanced students, they can attempt to implement a hamburger menu for the
mobile version of the navigation bar.
● Explore Further: Encourage students to explore responsive images (using srcset) or
CSS Grid for even more complex layouts.
Day 4: Debugging and Polishing the Landing Page
● Chrome DevTools is a powerful suite of tools that allow developers to inspect and
debug HTML, CSS, and JavaScript directly in the browser. Other browsers like Firefox
and Safari offer similar tools.
● Open DevTools by right-clicking on any part of the webpage and selecting "Inspect" or
pressing Ctrl + Shift + I.
● Elements Panel: Allows you to inspect and modify the HTML and CSS of the page.
● Console Panel: Useful for debugging JavaScript (though this will be covered in later
weeks).
● Network Panel: To inspect API calls and resources loaded (useful for debugging
slow-loading elements).
1. Inspecting Elements:
○ Hover over HTML elements in the Elements panel to see the corresponding part
of the webpage highlighted.
○ Click on an element in the HTML tree to view its CSS box model, styles, and
attributes.
2. CSS Box Model:
○ The box model represents how elements are sized and positioned on the page.
It consists of:
■ Content: The main content area of the element.
■ Padding: Space between the content and the border.
■ Border: The outline around the padding (if any).
■ Margin: Space between the border and adjacent elements.
○ DevTools provides a visual representation of this model, allowing students to
easily spot issues like extra margins or padding.
3. Live Editing of Styles:
○ DevTools allows you to temporarily modify CSS styles in real-time.
○ Example: Adjust the width, height, margin, or padding of an element directly in
the Styles panel.
○ Example: A product grid is overflowing the page on small screens. The student
can adjust the padding or width to fix the issue.
3. Inconsistent Responsiveness:
○ Test media queries by resizing the viewport in DevTools. Ensure that
breakpoints are applied correctly and that no elements are misaligned or
overflowing on smaller screens.
Hands-On Task:
● Students will use DevTools to inspect their landing page and identify any layout or
spacing issues.
● They will adjust margins, padding, and other styles to ensure that their landing page
appears correctly across different screen sizes.
● When you inspect the page, the .box overflows the .container.
● Students should identify the problem using DevTools and fix it by either adjusting the
.box width or applying overflow: hidden to the container.
Issue:
● On small screens, the .item might break the layout, causing overflow or misalignment.
● Ask students to use DevTools to spot the issue and fix it by either adding a media query
or adjusting the width of .item in percentages.
● Different browsers (Chrome, Firefox, Safari, Edge) may render HTML and CSS slightly
differently. It's essential to test websites across multiple browsers to ensure they look
and function consistently.
Hands-On Task:
● Students will test their landing page in at least three browsers (Chrome, Firefox,
Safari/Edge).
● They will identify and fix any browser-specific compatibility issues (e.g., Flexbox bugs,
inconsistent spacing, or font rendering issues).
● Use vendor prefixes to ensure backward compatibility with older browsers if necessary.
CSS Improvement Task:
Provide a partially styled product grid or header that is inconsistent or not responsive, and
students will be tasked with fixing it using their skills.
1. Visual Consistency:
○ Ensure consistent margins, padding, and fonts throughout the page.
○ Check for any unintended overflow or gaps that may have been missed earlier.
2. Refining Hover Effects and Animations:
○ Make sure hover effects and animations are smooth across all devices and
browsers.
○ Ensure that animations like the hover menu on product cards work seamlessly
on mobile, tablet, and desktop.
3. Testing Forms and Buttons:
○ Test any form elements (like search bars or login forms) to ensure they are
functioning properly.
○ Ensure that buttons have the correct hover effects and are clickable across all
screen sizes.
● Students will perform a final polishing session where they will refine the layout, fix any
lingering issues, and ensure the landing page is fully responsive and functional.
Task:
● Perform responsive testing and debugging on their landing page using browser
DevTools.
● Ensure that the product grid, header, and footer are responsive and correctly aligned
across all screen sizes.
● Test the landing page in different browsers to ensure compatibility and fix any
browser-specific issues.
● Optional Task: Students who finish early can run a Lighthouse audit in Chrome
DevTools and work on improving their page’s performance and accessibility.
Day 5: Integrating Components into the Landing Page
Students will apply hover effects on product cards, adding menus for Quick View, Add to
Wishlist, and Compare options. These menus will become visible when hovering over a
product card, adding an interactive element to the page.
Step-by-Step Guide:
Hands-On Task:
● Implement hover effects on the product cards, adding interactive menus that appear
when the user hovers over a product.
● Students will ensure the hover effects are smooth and responsive, providing a visually
appealing interaction.
Students will add smooth scrolling functionality to anchor links (e.g., "Back to Top" or internal
navigation links). This feature ensures a seamless scrolling experience when users navigate
between sections of the landing page.
Step-by-Step Guide:
1. Applying Smooth Scrolling with CSS:
○ Add the scroll-behavior property to the html element:
Hands-On Task:
● Students will add smooth scrolling functionality to any internal links on the page.
● They will test the scroll behavior using DevTools by clicking the links to ensure smooth
transitions between sections.
The hero/banner section of the landing page will be polished with CSS animations. This
includes adding fade-in effects for text and button animations to create a more dynamic and
engaging landing experience.
Step-by-Step Guide:
Hands-On Task:
● Students will apply animations to the hero section of the landing page, ensuring the
text fades in and the buttons respond to hover actions.
● They will focus on making the animations smooth and responsive.
Responsive Design for the Product Grid (45 minutes)
Students will ensure that the product grid is responsive across all devices—mobile, tablet, and
desktop. They will use media queries to adjust the layout, ensuring that product cards display
as a single column on mobile and as multiple columns on larger screens.
Step-by-Step Guide:
1. Mobile-First Grid:
○ Start with a single-column layout for mobile:
● Students will implement media queries to ensure the product grid is responsive across
all screen sizes.
● They will test their designs on mobile, tablet, and desktop views using DevTools to
ensure the grid adjusts properly.erly.
● Students will integrate all the components they've worked on throughout the day:
○ Implementing hover effects on product cards.
○ Adding smooth scrolling between sections.
○ Finalizing the hero section with animations.
○ Ensuring the product grid is fully responsive.
● Goal: By the end of this session, students should have a fully functioning landing page
that is visually engaging, responsive, and interactive.
Week 4 - Introduction to JavaScript
Explanation:
● JavaScript can be added to an HTML file either by using a <script> tag within the
HTML file or by linking to an external .js file.
Basic Syntax and Structure (45 minutes)
Variables in JavaScript:
Explanation: A variable is like a container that stores information we can use later. Just like
how you might store books in a box, in programming, we store values (like numbers or words) in
variables.
Analogy: Imagine a variable as a labeled box. You can store something inside (like a
number, a word, etc.), and whenever you need it, you can retrieve it using the label.
○ let name = "Sara"; is like labeling a box "name" and putting "Sara" inside it.
Data Types:
Basic Operations:
● Arithmetic: +, -, *, /, % (remainder).
● String Concatenation: Combine strings using the + operator.
Hands-On Task:
1. Ask students to create a JavaScript file and link it to their landing page.
2. Students will declare variables for a product name and price, and log the result in the
console:
Console Operations (30 minutes)
● The console is a tool that allows developers to output messages, inspect code behavior,
and debug.
Hands-On Task:
Steps:
● What is JavaScript?
● How to declare variables and perform basic operations.
● Using console.log to debug and output messages.
Understanding Conditionals:
Definition:
Real-World Analogy:
If/Else Statements:
● Syntax:
● Example:
Logical Operators:
● Explain how to make more complex decisions using operators like == (equality), ===
(strict equality), > (greater than), < (less than), && (and), || (or), and ! (not).
Hands-On Task:
● Create a script that checks the time of day and outputs a greeting:
Introduction to Functions:
Definition:
● A function is a reusable block of code designed to perform a particular task, which can
be called as many times as needed.
Real-World Analogy:
● Think of a function as a recipe in a cookbook. You can follow the recipe (function) to
make a meal (complete a task) whenever you’re hungry (need to execute the task).
Creating Functions:
● Syntax:
● Example:
● Parameters are like ingredients for your recipe. They allow you to pass values into
functions.
● Return values let you get something back from a function, like the final dish from your
recipe.
Hands-On Task:
● Create a function to check if a given year is a leap year:
Consolidation:
● Review the conditional statements and function examples given throughout the day.
● Encourage students to think of scenarios where they could use conditionals and
functions to solve problems or automate tasks.
Exercise:
● Ask students to create a small script that uses both conditionals and functions to
simulate a simple user login:
Exercise:
● Students should write a function that takes a temperature in Celsius and converts it to
Fahrenheit, then use a conditional to print whether it's hot or cold based on the
Fahrenheit temperature.
4. Explanation:
● Explain the Function: Describe how the celsiusToFahrenheit function
works, emphasizing the mathematical formula used for the conversion.
● Explain the Conditional Logic: Detail how the checkTemperature function
uses the result from the celsiusToFahrenheit function to determine if the
output message should say it's hot or cold.
● Test Cases: Explain why different values are tested and what the expected
outcomes are based on the input temperatures.
Day 3: Loops and Basic DOM Manipulation
What is a Loop?
● Definition: A loop in programming is a control flow statement that repeats a block of
code multiple times based on a condition.
● Real-World Analogy: Think of checking every mailbox in an apartment building one by
one; this repetitive action is similar to what loops do in a program.
Types of Loops:
For Loop
● Explanation: Used when the number of iterations is known before the loop starts.
● Syntax:
● Example
While Loop
● Explanation: Used when the condition needs to be evaluated before each iteration, and
the number of iterations is not known beforehand.
● Syntax
● Example:
Do/While Loop
● Explanation: Similar to the while loop, but guarantees that the loop will execute at
least once.
● Syntax:
● Example:
Hands-On Task:
● Task students with writing a for loop to iterate over an array of their favorite foods and
print each one.
● Definition: The DOM (Document Object Model) is a programming API for HTML and
XML documents. It represents the page so that programs can change the document
structure, style, and content.
● Diagram/Visual: Provide a simple visual of a DOM tree with elements like <html>,
<body>, <div>, <p>, and text nodes.
● When a web page is loaded, the browser creates a Document Object Model of the page.
● The HTML DOM model is constructed as a tree of Objects:
With the object model, JavaScript gets all the power it needs to create dynamic HTML:
The HTML DOM is a standard object model and programming interface for HTML. It defines:
In other words: The HTML DOM is a standard for how to get, change, add, or delete HTML
elements.
Accessing Elements:
● getElementById:
○ Retrieves an element by its ID.
○ Example:
● querySelector:
○ Returns the first element matching a specified CSS selector.
○ Example:
● querySelectorAll:
○ Returns all elements matching a specified CSS selector as a NodeList.
○ Example:
● Use a for loop to change the color of all header tags (<h1> to <h6>) on a page.
● Find all elements with the class description and update their text content to "Updated
description".
Create an Interactive Alert:
● Use a while loop to keep asking the user for their name until they enter it, then display it
in an alert.
Day 4: Arrays and Objects
What is an Array? (1 hour)
● Definition: An array is a special variable that can hold more than one value at a time,
organized in a list.
If you have a list of items (a list of car names, for example), storing the cars in single variables
could look like this:
However, what if you want to loop through the cars and find a specific one? And what if you had
not 3 cars, but 300?
An array can hold many values under a single name, and you can access the values by
referring to an index number.
Creating an Array
Syntax:
Examples:
OR
Accessing Array Elements
● Methods:
○ push(): Adds an element to the end of the array.
○ pop(): Removes the last element from the array.
● Example:
What is an Object?
In real life, objects are things like: houses, cars, people, animals, or any other subjects.
Object Properties
Car objects have the same properties, but the values differ from car to car.
Object Methods
Car objects have the same methods, but the methods are performed at different times.
● Task: Create an object representing a vehicle with properties for make, model, and color.
Hands-On Task:
Hands-On Task: Create an array of product objects and dynamically generate HTML content
based on this array.
● Task: Generate a list of products in HTML from the product array.
● Code:
● Task Description: Create an array called seasons containing the names of the four
seasons. Then, write code to print each season in the console.
● Code Example
Objective: Learn how to add and remove elements from an array using push, pop, shift, and
unshift.
● Task Description: Start with an array of fruits. Add 'Mango' to the end, remove 'Banana'
from the beginning, and then add 'Peach' to the beginning.
● Code Setup:
● Solution:
● Task Description: Given an array of numbers, find the first even number and print its
value.
● Code Setup:
● Task Description: Update the year of the car object to 2021, and add a new property
color with the value 'blue'.
● Code Setup:
● Solution:
Task:
● Utilize the array of product objects and JavaScript loops to dynamically generate the
product grid on the landing page.
Implementation:
● Review: Start by reviewing the array of product objects created earlier in the week.
● JavaScript Code
● Add event listeners to buttons on the product cards to enable interactive functionality
such as adding items to a cart.
Implementation:
Task:
● If there is a form on the landing page (e.g., a newsletter signup form), implement basic
JavaScript validation to ensure the form is filled out correctly before submission.
Implementation:
● Validation Code:
Week 5 : Advanced JS Concepts
Day 1: Advanced DOM Manipulation
Objective: Learn how to dynamically add new elements to the webpage using JavaScript
methods.
Setting Attributes:
● Task: Students create a new div element, set its class to new-div, and append it to a
specific section on their page.
● Code:
Objective: Understand how to remove elements from the DOM, either by using
removeChild() or the more recent remove() method.
Removing Elements:
● Task: Ask students to remove the first item from a list on their web page.
● Code:
Objective: Review and practice modifying existing elements in the DOM, including their
attributes and content.
Modifying Elements:
● Explanation: Besides setting attributes, you can directly change the styles, properties,
or inner HTML of an element.
● Example:
● Task: Instruct students to change the text color of all paragraph tags to blue on their
page.
● Code:
● Objective: Use the skills from earlier sessions to dynamically create product cards with
a button that adds them to a container.
● Implementation:
Remove a Product Card on Button Click
● Objective: Provide a button to remove the last product card from the display.
● Implementation:
Day 2: Introduction to Array Methods
Introduction to forEach (30 mins)
Objective:
Learn how to iterate over array elements using the forEach method to execute a function on
each element.
Explanation:
● Overview: forEach is a method that allows you to loop through each item in an array,
similar to a for loop, but with cleaner syntax and better abstraction.
● Syntax: array.forEach(function(element) { /* actions */ });
Example Code:
Hands-On Task:
● Task: Create an array of colors and use forEach to log each color to the console.
● Code:
Objective:
Understand how to use filter to create a new array filled with elements that pass a specified
test.
Explanation:
● Overview: filter creates a new array including elements where the test function
returns true and excluding those where it returns false.
● Syntax: let newArray = array.filter(element => condition);
Example Code:
Hands-On Task:
● Task: Filter out all products with a price greater than $20 from a product array.
● Code:
Objective:
Learn to use map to transform the elements of an array by applying a function to each element
and generating a new array.
Explanation:
● Overview: map modifies each item in the array and creates a new array with the
modified items.
● Syntax: let newArray = array.map(element => element modified);
Example Code:
Hands-On Task:
● Task: Apply a 10% discount to all products and display the updated prices.
● Code:
Objective:
Combine forEach, filter, and map to enhance the dynamic features of the landing page,
such as product displays and interactions.
Hands-On Task:
● Task: Utilize the array methods learned today to manage and display products on the
landing page dynamically.
○ Use forEach to display each product.
○ Use filter to show products under a specified price.
○ Use map to adjust product prices and display the new prices.
Objective:
Use the forEach method to iterate over a product array and display each product on the
landing page.
Details:
Objective:
Implement the filter method to display only those products that are priced below a specified
threshold.
Details:
● From the existing products array, filter out products that cost more than $500 and display
them.
Example Code and Task:
Objective:
Use the map method to apply a discount to all products and display the new prices.
Details:
● Apply a 10% discount to all products and update the display to reflect these new prices.
Objective:
Encourage students to integrate these tasks into the landing page, enhancing the overall
functionality and user experience.
Task:
Objective:
Learn to use the sort() method for organizing data within arrays, which is pivotal for
enhancing user interfaces like product listings.
● Sorting Basics:
○ Overview: The sort() method sorts the elements of an array in place and
returns the array.
○ Syntax: array.sort([compareFunction])
● Sorting Numbers and Strings:
○ Numbers are sorted by converting them to strings and comparing their
sequences of UTF-16 code units values.
○ Example:
● Sorting Objects:
○ Use Case: Sorting products by price.
○ Example:
2. Simple Search Algorithms (45 mins)
Objective:
Introduce basic techniques for searching through arrays, an essential operation for working with
data-driven applications.
● Linear Search:
○ Overview: A simple method for finding an element within a list by checking each
element in sequence.
○ Application: Finding a product by name.
○ Example:
Task Description:
● Sorting Products:
○ Objective: Use the sort() method to sort the product array by price in
ascending order and dynamically update the product display on the landing page.
○ Implementation:
document.getElementById('searchBar').addEventListener('input', function(e) {
let filteredProducts = products.filter(product =>
product.name.toLowerCase().includes(e.target.value.toLowerCase()));
displayProducts(filteredProducts); });
Day 4: JavaScript Events and Form Handling
1. Handling Forms with JavaScript (1 hour)
Objective:
Teach students how to effectively capture and validate user input from forms using JavaScript.
● Use preventDefault() within an event listener to prevent the form from being
submitted automatically, which is useful for when validation fails or you need to post data
via AJAX.
● Example:
Objective:
Demonstrate how to provide real-time feedback based on the validation results of form inputs.
● Show error messages next to the respective form field or use a modal/pop-up to alert the
user.
● Example:
4. Hands-On Task (1 hour)
Task Description:
Example Implementation:
JS Code:
document.getElementById('registerForm').addEventListener('submit', function(event) {
event.preventDefault();
let username = document.getElementById('username').value;
let email = document.getElementById('email').value;
if (!validateForm()) {
displayError('Please correct the errors before submitting.', this);
} else {
console.log('Successfully Registered!');
}
});
Day 5: Applying JavaScript to the Project
Dynamic Product Grid (1 hour)
Objective:
Leverage JavaScript to dynamically render products on the landing page, incorporating sorting
functionalities.
Key Actions:
● Sorting Feature:
○ Implement functionality that allows users to sort products by price or category.
○ Example Code:
Interactive Buttons (45 mins)
Objective:
Add event listeners to product card buttons for interactive actions like adding or removing
products.
Key Actions:
Objective:
Implement features allowing users to search and filter products based on their
preferences.
Key Actions:
document.getElementById('categoryFilter').addEventListener('change', function() {
let category = this.value;
let filteredProducts = products.filter(product => product.category === category);
displayProducts(filteredProducts);
});
Objective:
Implement and validate a simple login/register form, providing immediate feedback based on
user input.
Key Actions:
● Form Validation:
○ Validate input fields and show error messages if inputs are invalid.
○ Example Code:
document.getElementById('loginForm').addEventListener('submit', function(event) {
event.preventDefault();
let username = document.getElementById('username').value;
let password = document.getElementById('password').value;
if (!username || !password) {
alert('Both username and password are required!');
} else {
console.log('Form submitted');
// Proceed with form submission logic
}
});
Week 6 - Fetch API and Asynchronous
Processing
Key Concepts:
Example Explanation:
APIs are like waiters in a restaurant. You request a specific dish (data), and the waiter (API)
communicates your request to the kitchen (server) and brings back your dish (response) once
it's ready.
The Fetch API is a relatively new web browser feature but builds on older technologies such as
AJAX.
AJAX stands for Asynchronous JavaScript and XML. It was the first widely adopted technology
to allow websites to send requests without needing to reload the entire page. Before AJAX, if
you wanted to update something on your web page, you would need to reload the entire page -
which was clunky and inefficient.
AJAX allowed developers to make HTTP requests without needing a full-page refresh. This
technology revolutionized web development, but it had its limitations. AJAX requests were
limited to retrieving data from the same origin (domain/subdomain) as the page requested.
Enter the Fetch API. Brought about by newer web browsers, this technology had all of the
power of AJAX but with no cross-origin security issues and added support for more HTTP
methods like PUT and DELETE.
It's a two-step process. First, you send a request to the desired URL using the fetch() method.
Next, you handle the response with the .then() method. In this case, we're not doing anything
with the code yet, but you could use this same code to parse HTML documents, send data over
POST requests, and more.
Sending a Request
The simplest way to make a request is with the global fetch() method. This method takes two
parameters - the URL of the resource you want to retrieve and an optional configuration object.
For example, if you wanted to get an HTML document from a website, you could use the
following code:
This code will send a GET request to the URL specified and then alert the response (in this
case, an HTML document). It's important to note that if the request fails, the .then() method will
return an error. It is your job as a developer to handle these errors gracefully.
You can also use the Fetch API to make POST requests. This is useful if you need to send data
to a web server, such as when submitting forms or uploading files.
To make a POST request, you need to add the configuration object to the fetch() method. This
object should include the HTTP method (in this case, POST) and any data you want to send in
the body of the request.
For example, if you wanted to submit an HTML form with two fields - name and email - your
code might look like this:
This code will collect data from an HTML form and submit it via a POST request. Again, if the
request fails, you'll want to use some error-handling logic to handle the situation gracefully.
Error Handling
No matter what you're trying to accomplish with the Fetch API, it's essential to have a good
error-handling strategy. This is especially true for POST requests, which often require sensitive
data.
The simplest way to handle errors is with a try/catch block. You can wrap your code in this block
and then use the catch() method to alert an error if something goes wrong.
For example, if you were making a POST request, your code could look like this:
Hands-On Task (1 hour)
Fetch Data from a Public API:
● Use the Fetch API to request data from a public API, such as a product catalog or
weather service.
● Task: Display the fetched data on the landing page, enhancing the real-time data
handling capabilities of the project.
Day 2: Introduction to Async/Await and More API Integration
Async/Await (1 hour)
● Async Functions:
○ Overview: An async function is a function declared with the async keyword.
Async functions are instances of the AsyncFunction constructor, and the await
keyword is permitted within them.
○ Syntax:
● Properties:
○ Returns a promise.
○ Allows the use of await inside the function body.
● Await Keyword:
○ Usage: The await keyword is used to pause async function execution until a
Promise is fulfilled or rejected, and to resume execution of the async function
after fulfillment.
○ Example:
Hands-On Task:
● Task: Create an async function that fetches user data from an API and logs it.
● Example Code:
● Hands-On Task:
○ Task: Fetch and display a list of products, handling pagination.
○ Example Code:
Task Description:
● Fetch product data using async/await and update the product grid dynamically on the
page.
● Implement error handling to display user-friendly error messages if the API request fails.
Day 3: Working with Dynamic Data and Advanced Array
Methods
Advanced Array Methods (1 hour 30 mins)
● Reduce Method:
○ Overview: reduce() is used to execute a reducer function on each element of
the array, resulting in a single output value.
○ Example: Calculate the total price of items in a shopping cart.
● Find Method:
○ Usage: find() returns the value of the first element in the array that satisfies
the provided testing function.
○ Example: Find a specific product by name.
● Implement interactive features that allow users to sort, filter, and search the data
displayed on the page.
● Hands-On Examples:
○ Sort products by price.
○ Filter products based on availability.
○ Implement a search functionality to find products by name.
Task Descriptions:
Objective:
Introduce students to the try...catch statement for handling exceptions in JavaScript code,
which is crucial for maintaining application stability, especially when dealing with external data
sources like APIs.
● Try...Catch Basics:
○ Overview: The try...catch structure allows you to test a block of code for
errors while it is being executed.
○ Syntax:
Objective:
Guide students through using browser developer tools to effectively identify and resolve
JavaScript issues.
Objective:
Instruct students on managing errors in asynchronous operations using async/await with
try...catch for more robust code.
Explanation: This function attempts to fetch user data from an API. If the
fetch fails or the data cannot be parsed, the error is caught and logged.
● Students will identify and fix a bug where a "Add to Cart" button does not update the cart
count:
○ Use the console to log values and set breakpoints in the event handler function
for the button to trace the execution and find the logic error.
Day 5: Applying Dynamic API Data to the Cart and Login
Pages
Dynamic Cart Implementation (1 hour)
Objective:
Enable students to integrate dynamic data into the Cart Page, enhancing functionality with
JavaScript for a real-time interactive experience.
Detailed Instructions:
Objective:
Guide students through creating interactive login and registration pages using HTML, CSS, and
JavaScript.
Step-by-Step Process:
● Page Design:
○ Students should first complete the HTML/CSS layout for the Login/Register page.
○ Ensure forms are user-friendly and visually appealing.
● Simulating User Authentication:
○ Use JavaScript to simulate a login process with API requests.
○ Example Code:
Objective:
Start incorporating dynamic data into additional pages, such as the Account Page, to display
user-specific information.
Implementation Guide:
● Fetch and display data relevant to the logged-in user, enhancing the personalization of
the website.
● Example Code:
Week 7 : Local Storages, SessionStorages and
Validations
Objective:
Provide an in-depth exploration of localStorage and sessionStorage, including their
practical applications, benefits, and limitations.
Objective:
Walk students through the creation of a persistent shopping cart using local storage,
demonstrating data addition, retrieval, and removal.
Step-by-Step Guide:
● Explain how to remove items from the cart and update local storage.
● Interactive Task:
Hands-On Tasks
Duration: 1 hour
● Add products to a shopping cart and reflect changes immediately on the Cart Page using
local storage.
● Example Task:
● Create functionality to remove items from the cart through the user interface, updating
local storage accordingly.
● Example Code:
Day 2: Dynamic Product Details Page
Designing the Product Details Page
Duration: 45 minutes
Objective:
Instruct students on how to structure and style the Product Details Page, incorporating essential
elements that enhance user engagement and product presentation.
Step-by-Step Guide:
● Page Layout: Explain the key components of a product details page including product
images, descriptions, pricing information, and customer reviews.
● Styling Tips: Discuss the importance of a clean layout and responsive design to
accommodate various device sizes.
● Example Layout:
Duration: 1 hour
Objective:
Teach students how to retrieve and display product information dynamically, leveraging
JavaScript and local storage or API data.
Duration: 45 minutes
Objective:
Implement interactive features that allow users to interact with product details, such as adding
items to the cart.
● Add to Cart Function: Explain how to link the "Add to Cart" button with local storage to
update the cart contents.
● Dynamic Content Updates: Show how to handle different product options that may
affect the displayed content (e.g., color choices, sizes).
● Example Functionality:
document.querySelector('.btn-add-to-cart').addEventListener('click', function() {
const product = {
id: productId,
name: document.querySelector('.product-name').textContent,
price: parseFloat(document.querySelector('.product-price').textContent.replace('$', ''))
};
addToCart(product);
alert('Added to cart!');
});
Hands-On Task
Duration: 30 minutes
● Task: Students will create a dynamic product details page that fetches and displays
product information based on user selection or input.
● Expected Outcomes:
○ Properly fetch and display product data.
○ Implement adding products to the cart directly from the product details page
using local storage.
○ Ensure the page updates dynamically when different options are selected.
Day 3: Checkout Page and Form Validation
Checkout Page Layout
Duration: 45 minutes
Objective:
Guide students through the process of creating a detailed checkout page layout that includes
necessary input fields for completing a purchase.
Step-by-Step Guide:
● Designing the Layout: Explain the importance of a user-friendly and intuitive checkout
process.
● Essential Elements:
○ Input Fields: Include fields for name, address, credit card details, and other
necessary billing and shipping information.
○ Example Layout:
Form Validation
Duration: 1 hour
Objective:
Teach students how to implement client-side form validation to ensure data integrity before
submission.
Detailed Instruction and Code Example:
● JavaScript Validation:
○ Discuss the importance of validating input to protect against incorrect or
malicious data.
○ Show how to check for empty fields, validate email formats, and ensure that
numerical inputs are correct.
○ Example Code:
document.getElementById('checkoutForm').addEventListener('submit', function(event) {
const name = document.getElementById('name').value;
const address = document.getElementById('address').value;
const card = document.getElementById('card').value;
if (!name || !address || !/^\d{16}$/.test(card)) {
alert('Please check your inputs.');
event.preventDefault(); // Stop the form from submitting
}
});
Duration: 45 minutes
Objective:
Enable students to dynamically calculate and display the total costs on the Checkout Page,
enhancing user experience by providing immediate feedback on cost changes.
● Calculating Totals: Use JavaScript to sum up the cart items, calculate taxes, and add
shipping costs.
● Displaying the Total: Show how to update the total price dynamically as users change
their cart or enter promo codes.
● Example Functionality:
Hands-On Task
Duration: 30 minutes
● Task: Students will finalize the Checkout Page by implementing dynamic calculations
and robust form validation.
● Expected Outcomes:
○ Build a functional Checkout Page with all required input fields.
○ Ensure all data is validated before allowing the form to submit.
○ Correctly calculate and display the total amount due, updating in real-time as the
user makes adjustments.
Day 4: Building the Account Page and User-Specific Data
Duration: 45 minutes
Objective:
Educate students on how to design and structure an Account Page that enhances user
experience by providing personalized content.
Detailed Explanation:
● Layout Considerations:
○ Discuss the essential elements of an Account Page, including user profile details
and order history.
○ Example Layout:
Duration: 45 minutes
Objective:
Show students how to fetch and display dynamic data on the Account Page, simulating a
realistic user experience.
Step-by-Step Instruction:
function fetchUserData() {
// Simulated API call
const userData = { name: 'John Doe', email: '[email protected]', orders: [123, 456] };
document.getElementById('userName').textContent = userData.name;
document.getElementById('userEmail').textContent = userData.email;
userData.orders.forEach(order => {
const li = document.createElement('li');
li.textContent = `Order ID: ${order}`;
document.getElementById('orderList').appendChild(li);
});
}
fetchUserData();
Duration: 45 minutes
Objective:
Teach students how to allow users to update their profile information, emphasizing data
persistence and interaction.
Detailed Guide:
<form id="editProfileForm">
<label for="newEmail">Update Email:</label>
<input type="email" id="newEmail" required>
<button type="submit">Update</button>
</form>
<script>
document.getElementById('editProfileForm').addEventListener('submit', function(event) {
event.preventDefault();
const newEmail = document.getElementById('newEmail').value;
localStorage.setItem('userEmail', newEmail);
alert('Email updated successfully!');
document.getElementById('userEmail').textContent = newEmail;
});
</script>
Hands-On Task
Duration: 45 minutes
● Task: Students will build the Account Page, implementing functionality for displaying and
editing user data.
● Expected Outcomes:
○ Correctly display dynamic user information fetched from simulated sources.
○ Enable users to update their profile details and instantly see the changes on the
page.
○ Manage user data effectively using local storage or simulated API responses.
Day 5: Integrating Local Storage and Finalizing Dynamic
Pages
Cart Integration with Local Storage
Duration: 1 hour
Objective:
Ensure that the cart functionality is fully persistent across user sessions using local storage,
including the ability to add and remove items effectively.
Detailed Guide:
function addToCart(product) {
let cart = JSON.parse(localStorage.getItem('cartItems')) || [];
cart.push(product);
localStorage.setItem('cartItems', JSON.stringify(cart));
updateCartDisplay();
}
function removeFromCart(productId) {
let cart = JSON.parse(localStorage.getItem('cartItems'));
cart = cart.filter(item => item.id !== productId);
localStorage.setItem('cartItems', JSON.stringify(cart));
updateCartDisplay();
}
function updateCartDisplay() {
const cart = JSON.parse(localStorage.getItem('cartItems')) || [];
const cartContainer = document.getElementById('cartContents');
cartContainer.innerHTML = ''; // Clear current cart display
cart.forEach(item => {
const itemElement = document.createElement('div');
itemElement.textContent = `${item.name} - $${item.price}`;
cartContainer.appendChild(itemElement);
});
}
Dynamic Product Display
Duration: 30 minutes
Objective:
Ensure that the Product Details Page dynamically retrieves and displays product data from local
storage or an API.
function loadProductDetails(productId) {
// Assuming product details are fetched or retrieved from local storage
const product = JSON.parse(localStorage.getItem('productDetails'));
document.getElementById('productName').textContent = product.name;
document.getElementById('productPrice').textContent = `$${product.price}`;
document.getElementById('addToCartButton').onclick = () => addToCart(product);
}
Duration: 1 hour
Objective:
Review and finalize the Checkout and Account Pages to ensure they function correctly with
accurate calculations and valid user interactions.
Duration: 1 hour
● Comprehensive Debugging:
○ Instruct students on debugging techniques using browser DevTools.
○ Identify common issues with localStorage, dynamic data handling, and form
submissions.
○ Debugging Tips:
Hands-On Task
Duration: 30 minutes
● Task: Fully integrate and test all dynamic functionalities across the site, particularly
focusing on the cart, checkout, and account features.
● Expected Outcomes:
○ Ensure that the cart updates and persists across sessions.
○ Confirm that the checkout process calculates totals correctly and validates user
input effectively.
○ Verify that the account page displays and updates user information correctly.
Week 8 : Adding Finishing Touches
Duration: 1 hour
Objective:
Conduct a thorough review of each page within the project to ensure completeness,
functionality, and cohesiveness across the website.
Duration: 1 hour
Objective:
Enhance the overall aesthetics and usability of the site, ensuring a seamless experience across
different devices.
● UI Enhancements:
○ Improve navigation consistency and accessibility.
○ Refine hover effects on buttons and links for better visual feedback.
○ Ensure responsiveness across devices—test on mobile, tablet, and desktop for
layout integrity.
○ Example CSS for Refined Hover Effects:
Duration: 1 hour
Objective:
Final testing of all interactive and dynamic elements to ensure they are error-free and enhance
the user experience.
● Product Grid: Confirm that sorting, filtering, and searching functionalities are working as
intended.
● Add-to-Cart: Test adding, removing, and updating items in the cart.
● Form Operations: Verify form submissions on the Checkout and Account Pages for
accuracy and responsiveness to user input.
Hands-On Task
Duration: 1 hour
● Task: Conduct a final review and polish of the project. Students will iteratively refine
each page based on feedback and testing.
● Expected Outcomes:
○ Each page should load correctly with all functionalities intact.
○ User interactions like adding to cart, checking out, and updating profile details
should work without errors.
○ Enhance user interface elements for a polished, professional look.
Day 2: Debugging and Error Handling
Common JavaScript Errors
Duration: 1 hour
Objective:
Equip students with the skills to identify and resolve frequent JavaScript errors, enhancing their
debugging capabilities.
Detailed Instruction:
Duration: 1 hour
Objective:
Reinforce the use of try...catch blocks to manage exceptions and ensure applications
handle errors gracefully.
3. Debugging Tools
Duration: 45 minutes
Objective:
Introduce students to powerful browser developer tools that aid in debugging JavaScript and
web applications.
Step-by-Step Instruction:
4. Hands-On Task
Duration: 30 minutes
Duration: 1 hour
Objective:
Teach students the importance of ensuring their web application works consistently across
different web browsers.
Detailed Explanation:
● Browser Differences:
○ Discuss how different browsers can render HTML, CSS, and JavaScript
differently, leading to potential issues in layout and functionality.
○ Explain the concept of "browser quirks" and common pitfalls.
● Testing Tools:
○ Introduce tools like BrowserStack for testing web applications on multiple
browser versions and operating systems.
○ Demonstrate how to use built-in browser developer tools to simulate different
environments.
2. Mobile Responsiveness
Duration: 1 hour
Objective:
Ensure that the project is fully responsive and functions effectively on mobile devices, utilizing
modern CSS techniques.
3. Manual Testing
Duration: 45 minutes
Objective:
Engage students in hands-on testing of their web applications, focusing on usability and
interactive elements.
● Interactive Elements:
○ Guide students to test all interactive components such as buttons, forms, links,
and navigation menus.
○ Check for smooth operation and user-friendly feedback.
● Form Functionality:
○ Test all forms on the website for proper data capture and validation.
○ Ensure that error handling and success messages display correctly.
4. Hands-On Task
Duration: 45 minutes
Objective:
Guide students through the process of refining the CSS styling to give the website a unique and
professional appearance.
Detailed Activities:
Objective:
Prepare students to effectively present their projects, focusing on the ability to explain and
demonstrate the project's features and the challenges they overcame.
● Presentation Skills:
○ Teach students how to structure a clear and engaging presentation.
○ Discuss the key points to cover: introduction to the project, demonstration of
features, discussion of technologies used, and challenges faced during
development.
● Practice Sessions:
○ Have students practice their presentations in small groups or in a simulated
environment.
○ Provide feedback on their delivery, clarity, and the overall flow of the
presentation.
Day 5: Project Presentation Day
1. Final Review and Rehearsal
Duration: 1 hour
Objective:
Conduct a final review and rehearsal to ensure that all students are prepared and confident in
their presentation skills.
Activities:
● Technical Check:
○ Ensure that all technical aspects such as project deployment, live demo
readiness, and presentation equipment are functioning properly.
● Rehearsal:
○ Allow each student or group to do a final run-through of their presentation.
○ Make last-minute adjustments based on feedback and technical checks.
2. Presentation of Projects
Duration: 2 hours
Objective:
Each student or group presents their project to the class, instructors, or a panel of invited
guests.
Presentation Format: