View the live project here: https://olitech1010.github.io/rayvalley-html-css-js-project-tut/
- Introduction
- Project Overview
- HTML Basics
- CSS Fundamentals
- JavaScript Essentials
- Responsive Design
- Project Structure
- Key Concepts Explained
- Practice Exercises
- Resources
Welcome to the RAMSYS web development tutorial! This project is designed to teach beginners/intermediate devs the fundamentals of HTML, CSS, and JavaScript through a real-world website example.
https://www.linkedin.com/in/olitech1010
- HTML: Structure and semantic markup
- CSS: Styling, layout, and responsive design
- JavaScript: Interactive functionality and DOM manipulation
- Best Practices: Clean code, comments, and organization
- Basic computer skills
- A text editor (VS Code, Sublime Text, or any code editor)
- A web browser (Chrome, Firefox, Safari, or Edge)
- No prior coding experience required!
Ray Valley Farms is a modern, responsive website for an agricultural business. The project includes:
- 6 HTML Pages: Home, About, Gallery, Login, Signup, and Contact
- Responsive Design: Works on desktop, tablet, and mobile devices
- Interactive Menu: Hamburger menu for mobile navigation
- Modern Styling: Clean, professional design with CSS variables
- Image Gallery: Learn CSS Grid with a beautiful image gallery
- Google Maps Integration: Embedded maps for location display
- Form Handling: Login and signup forms with validation
- HTML5 (Structure)
- CSS3 (Styling)
- Vanilla JavaScript (Functionality)
- Google Fonts (Typography)
HTML (HyperText Markup Language) is the foundation of every website. It provides the structure and content of web pages.
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Metadata goes here -->
</head>
<body>
<!-- Content goes here -->
</body>
</html>Explanation:
<!DOCTYPE html>tells the browser this is an HTML5 document<html>is the root element containing all content<head>contains metadata (title, links to CSS, etc.)<body>contains visible content
Header (<header>)
- Contains logo, navigation, and login button
- Provides site-wide navigation
Navigation (<nav>)
- Contains links to different pages
- Helps users navigate the website
Section (<section>)
- Groups related content together
- Example: Hero section, About section, etc.
Footer (<footer>)
- Contains footer information
- Usually at the bottom of the page
Why Semantic HTML?
- Better accessibility for screen readers
- Easier to maintain and understand
- Better SEO (Search Engine Optimization)
Headings (<h1>, <h2>, etc.)
<h1>Main Title</h1>
<h2>Subtitle</h2><h1>is the most important (largest)- Use headings in order (h1 → h2 → h3)
Paragraphs (<p>)
<p>This is a paragraph of text.</p>Links (<a>)
<a href="about.html">About Us</a>hrefattribute specifies the destination- Can link to other pages or external websites
Images (<img>)
<img src="./images/logo.png" alt="Ray Valley Logo">srcis the image file pathaltprovides text description (important for accessibility)
Buttons (<button>)
<button class="btn-primary">Click Me</button>Lists (<ul>, <ol>, <li>)
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul><ul>= unordered list (bullets)<ol>= ordered list (numbers)<li>= list item
Forms (<form>)
<form action="#" method="POST">
<input type="email" name="email" required>
<button type="submit">Submit</button>
</form>- Used to collect user input
actionspecifies where to send datamethodspecifies HTTP method (GET or POST)
Attributes provide additional information about elements:
<img src="image.jpg" alt="Description" class="logo" id="main-logo">Common attributes:
class: Used for CSS styling (can have multiple classes)id: Unique identifier (only one per page)src: Source file pathalt: Alternative texthref: Link destinationtype: Input type (text, email, password, etc.)required: Makes form field mandatory
CSS (Cascading Style Sheets) controls the appearance and layout of HTML elements. It makes websites beautiful and responsive.
What are CSS Variables? CSS variables allow you to store values that can be reused throughout your stylesheet.
How They Work:
:root {
--color-primary: #53C351;
--spacing-md: 20px;
}
.button {
background-color: var(--color-primary);
padding: var(--spacing-md);
}Benefits:
- Easy to maintain: Change color once, updates everywhere
- Consistent design: All buttons use the same color
- Better organization: All design values in one place
Variables Used in This Project:
- Colors:
--color-primary,--color-text-primary, etc. - Spacing:
--spacing-xs,--spacing-sm,--spacing-md, etc. - Font sizes:
--font-size-base,--font-size-lg, etc. - Border radius:
--radius-sm,--radius-md, etc.
Element Selector
p {
color: black;
}- Styles all
<p>elements
Class Selector
.btn-primary {
background-color: green;
}- Styles elements with
class="btn-primary" - Can be used multiple times
ID Selector
#hamburger-icon {
width: 30px;
}- Styles element with
id="hamburger-icon" - Should be unique (only one per page)
Descendant Selector
nav a {
color: black;
}- Styles
<a>elements inside<nav>
Pseudo-classes
a:hover {
color: green;
}:hover- when mouse hovers over element:active- when element is clicked:focus- when element has focus
Every HTML element is a box with:
- Content: The actual content (text, image, etc.)
- Padding: Space inside the element
- Border: Border around the element
- Margin: Space outside the element
.element {
padding: 20px; /* Space inside */
border: 1px solid black; /* Border */
margin: 10px; /* Space outside */
}box-sizing: border-box
* {
box-sizing: border-box;
}- Makes padding and border included in width/height
- Prevents elements from being wider than expected
Flexbox makes it easy to create flexible layouts.
Container (Parent)
.container {
display: flex;
justify-content: center; /* Horizontal alignment */
align-items: center; /* Vertical alignment */
gap: 20px; /* Space between items */
}Common Flexbox Properties:
display: flex- Makes container a flex containerflex-direction: row/column- Direction of itemsjustify-content- Horizontal alignmentalign-items- Vertical alignmentgap- Space between items
Example from Project:
header {
display: flex;
justify-content: space-around;
align-items: center;
}- Header items are arranged horizontally
- Evenly spaced
- Vertically centered
Static (Default)
- Elements flow in normal document order
Relative
- Positioned relative to its normal position
- Can use
top,right,bottom,left
Absolute
- Positioned relative to nearest positioned ancestor
- Removed from normal flow
Fixed
- Positioned relative to viewport
- Stays in place when scrolling
- Used for mobile menu in this project
Example:
.mobile-menu-overlay {
position: fixed;
top: 0;
right: -100%;
}Primary Button
.btn-primary {
background-color: var(--color-primary);
color: white;
border: none;
border-radius: 10px;
padding: 0 20px;
cursor: pointer;
}- Green background
- Used for main actions (Login, Submit, etc.)
Secondary Button
.btn-secondary {
background-color: transparent;
color: black;
border: none;
}- No background
- Used for less important actions
Why Two Button Types?
- Visual hierarchy: Primary buttons stand out more
- User guidance: Shows which action is most important
- Consistent design: All buttons follow same pattern
Transitions
.button {
transition: background-color 0.2s ease;
}
.button:hover {
background-color: darkgreen;
}- Smoothly changes property over time
- Makes interactions feel polished
In This Project:
- Menu slides in smoothly
- Buttons change color on hover
- Links have smooth color transitions
JavaScript makes websites interactive. It can:
- Respond to user actions (clicks, typing, etc.)
- Modify page content
- Handle form submissions
- Create dynamic effects
What is the DOM? The DOM is a representation of your HTML that JavaScript can interact with.
Selecting Elements:
// By ID
const menu = document.getElementById('mobile-menu');
// By class (returns first match)
const button = document.querySelector('.btn-primary');
// By class (returns all matches)
const buttons = document.querySelectorAll('.btn-primary');Why We Use It:
- To find elements on the page
- To modify their properties
- To add event listeners
Event listeners wait for user actions and respond to them.
Syntax:
element.addEventListener('event', function() {
// Code to run when event happens
});Common Events:
click- When element is clickedkeydown- When key is pressedresize- When window is resizedload- When page finishes loading
Example from Project:
hamburgerIcon.addEventListener('click', function() {
openMenu();
});- When hamburger icon is clicked, open the menu
Functions are reusable blocks of code.
Function Declaration:
function openMenu() {
mobileMenu.classList.add('active');
}Function Expression:
const openMenu = function() {
mobileMenu.classList.add('active');
};Arrow Function (Modern):
const openMenu = () => {
mobileMenu.classList.add('active');
};Why Use Functions?
- Reusable code
- Better organization
- Easier to maintain
Adding Classes:
element.classList.add('active');Removing Classes:
element.classList.remove('active');Checking if Class Exists:
if (element.classList.contains('active')) {
// Do something
}Changing Styles:
element.style.overflow = 'hidden';Example from Project:
function openMenu() {
mobileMenu.classList.add('active');
menuBackdrop.classList.add('active');
document.body.style.overflow = 'hidden';
}The event object contains information about the event.
document.addEventListener('keydown', function(event) {
if (event.key === 'Escape') {
closeMenu();
}
});event.keytells us which key was pressedevent.targettells us which element triggered the event
document.addEventListener('DOMContentLoaded', function() {
// Code runs after HTML is loaded
});Why We Use It:
- Ensures HTML is loaded before JavaScript runs
- Prevents errors from trying to access elements that don't exist yet
How It Works:
- User clicks hamburger icon
- JavaScript adds
activeclass to menu - CSS transitions menu into view
- User can close menu multiple ways:
- Click X button
- Click backdrop
- Press Escape key
- Click menu link
Code Flow:
// 1. Get elements
const hamburgerIcon = document.getElementById('hamburger-icon');
const mobileMenu = document.getElementById('mobile-menu');
// 2. Define functions
function openMenu() {
mobileMenu.classList.add('active');
}
function closeMenu() {
mobileMenu.classList.remove('active');
}
// 3. Add event listeners
hamburgerIcon.addEventListener('click', openMenu);Responsive design makes websites work on all screen sizes: desktop, tablet, and mobile.
Media queries apply different styles based on screen size.
Syntax:
@media screen and (max-width: 750px) {
/* Styles for screens 750px and smaller */
}Breakpoints Used:
- Desktop: Above 768px (default styles)
- Tablet: 768px and below
- Mobile: 750px and below
- Small Mobile: 480px and below
Example:
/* Desktop: Show navigation */
.nav {
display: flex;
}
/* Mobile: Hide navigation, show hamburger */
@media screen and (max-width: 750px) {
.nav {
display: none;
}
.hamburger {
display: block;
}
}What It Means:
- Design for mobile first
- Add styles for larger screens with media queries
- Progressive enhancement
Benefits:
- Faster on mobile devices
- Better user experience
- Easier to maintain
1. Flexible Images
img {
max-width: 100%;
height: auto;
}- Images scale to fit container
- Maintains aspect ratio
2. Flexible Layouts
.hero {
flex-direction: column; /* Stack on mobile */
}
@media screen and (min-width: 768px) {
.hero {
flex-direction: row; /* Side by side on desktop */
}
}3. Responsive Typography
h1 {
font-size: 28px; /* Mobile */
}
@media screen and (min-width: 768px) {
h1 {
font-size: 40px; /* Desktop */
}
}4. CSS Order Property
.money-content {
order: -1; /* Text appears first on mobile */
}
.money-image {
order: 1; /* Image appears after text */
}- Changes visual order without changing HTML
- Text appears before images on mobile
ray-valley-main/
│
├── index.html # Home page
├── about.html # About page with video and images
├── gallery.html # Image gallery page (CSS Grid)
├── login.html # Login page
├── signup.html # Sign up page
├── contact.html # Contact page with Google Maps
│
├── css/
│ └── style.css # All styles (variables, layout, responsive)
│
├── javascript/
│ └── script.js # Mobile menu functionality
│
├── images/
│ ├── logo.png
│ ├── bg.png
│ ├── Aerial_view_of_farm.jpeg
│ ├── Agricultural_machinery.jpg
│ ├── cattle farm.jpg
│ ├── farmer at farm.jpg
│ └── ... (many more images)
│
└── README.md # This file
HTML Files
- Each page has its own HTML file
- All pages share the same header and footer structure
- Consistent navigation across all pages
- Footer includes: About, Quick Links, Contact Info, and Social Media
CSS File
- All styles in one file for simplicity
- Organized by sections with comments
- CSS variables at the top
- Responsive design with mobile-first approach
JavaScript File
- Separate file for better organization
- Loaded at end of HTML for performance
- Handles mobile menu functionality
Using HTML elements that describe their purpose:
<header>for header content<nav>for navigation<section>for content sections<footer>for footer
Benefits:
- Better accessibility
- Easier to understand
- Better SEO
Storing reusable values:
:root {
--color-primary: #53C351;
}Benefits:
- Easy to maintain
- Consistent design
- Quick theme changes
Modern layout method:
.container {
display: flex;
justify-content: center;
}Benefits:
- Easy alignment
- Responsive layouts
- Less code than old methods
Code that responds to user actions:
button.addEventListener('click', function() {
// Do something
});Benefits:
- Interactive websites
- Better user experience
- Dynamic content
Designing for mobile, then enhancing for desktop:
- Faster mobile performance
- Better user experience
- Easier maintenance
Modern layout system for two-dimensional layouts:
.gallery-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
}Benefits:
- Easy to create responsive grids
- Automatic layout adjustment
- Perfect for image galleries
Embedding interactive maps using iframes:
<iframe src="https://www.google.com/maps/embed?..."
width="100%"
height="450">
</iframe>Benefits:
- Interactive location display
- Easy navigation for users
- Professional appearance
HTML5 form validation attributes:
<input type="email" required minlength="8">Benefits:
- Built-in browser validation
- Better user experience
- Prevents invalid submissions
The footer uses CSS Grid for a responsive multi-column layout:
.footer-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}Footer Sections:
- About: Company description
- Quick Links: Navigation links
- Contact: Contact information
- Social Media: Social icons and follow text
Benefits:
- Organized information
- Easy navigation
- Professional appearance
- Responsive grid layout
Using proper CSS properties to prevent text overflow:
word-wrap: break-word;
max-width: 100%;
box-sizing: border-box;Benefits:
- Prevents text from breaking layout
- Better mobile experience
- Content stays within containers
-
Change Colors
- Find CSS variables in
style.css - Change
--color-primaryto a different color - See how it updates throughout the site
- Find CSS variables in
-
Add a New Section
- Add a new section to
index.html - Style it using existing classes
- Make it responsive
- Add a new section to
-
Modify Button Text
- Find a button in HTML
- Change its text
- See the change in browser
-
Add a New Page
- Copy
about.html - Create
services.html - Update navigation links
- Copy
-
Explore the Gallery Page
- Open
gallery.html - See how CSS Grid creates responsive image layouts
- Try adding more images to the gallery
- Open
-
Add Hover Effects
- Add hover effect to images
- Use CSS transitions
- Experiment with different effects
-
Create New Button Style
- Add a new button class
- Use CSS variables
- Apply to multiple buttons
-
Add Form Validation
- Add JavaScript to validate forms
- Show error messages
- Prevent invalid submissions
-
Improve Mobile Menu
- Add animation to menu items
- Add close on outside click
- Add keyboard navigation
-
Add Dark Mode
- Create dark mode CSS variables
- Add toggle button
- Save preference in localStorage
-
Add Smooth Scrolling
- Implement smooth scroll to sections
- Add scroll animations
- Create scroll-to-top button
-
Form Submission
- Connect forms to backend
- Add loading states
- Show success/error messages
-
Performance Optimization
- Optimize images
- Minify CSS/JS
- Add lazy loading
-
Enhance the Gallery
- Add lightbox functionality (click image to view larger)
- Add image filtering (filter by category)
- Add image captions with animations
HTML:
CSS:
JavaScript:
Responsive Design:
Code Editors:
- VS Code (Recommended)
- Sublime Text
- Atom
Browser DevTools:
- Chrome DevTools (F12)
- Firefox Developer Tools
- Safari Web Inspector
Online Resources:
- CodePen - Practice coding
- GitHub - Version control
- Stack Overflow - Get help
The gallery page demonstrates CSS Grid, a powerful layout system for creating responsive image galleries.
Key Concepts:
- CSS Grid: Two-dimensional layout system
- auto-fit: Automatically adjusts number of columns
- minmax(): Sets minimum and maximum column widths
- Hover Effects: Interactive image scaling on hover
How It Works:
.gallery-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
}This creates a responsive grid that automatically adjusts based on screen size.
A complete registration form demonstrating:
- Multiple input types (text, email, tel, password)
- Form validation (required, minlength)
- Checkbox for terms and conditions
- Password confirmation field
The contact page includes an embedded Google Map showing the business location in Accra, Ghana.
How to Embed Maps:
- Get the Google Maps share link
- Convert to embed format
- Use iframe to display the map
All content is centered on mobile devices for better readability:
- Text alignment: center
- Images: auto margins
- Buttons: centered with flexbox
- Forms: centered inputs
The footer is now a comprehensive section with:
- Grid Layout: Responsive 4-column layout (stacks on mobile)
- Social Icons: Integrated social media icons
- Contact Information: Quick access to contact details
- Quick Links: Easy navigation to all pages
- Copyright: Footer bottom with copyright notice
Applied to All Pages:
- index.html
- about.html
- gallery.html
- contact.html
- login.html
- signup.html
A: CSS variables make it easy to maintain consistent design. Change a color once, and it updates everywhere it's used.
A:
classcan be used multiple times (for styling groups of elements)idshould be unique (for targeting specific elements)
A: So HTML loads first, then JavaScript runs. This prevents errors from trying to access elements that don't exist yet.
A:
paddingis space inside the elementmarginis space outside the element
A: Media queries apply different styles based on screen size. They let you create responsive designs that work on all devices.
A:
- Flexbox: One-dimensional layout (row OR column)
- Grid: Two-dimensional layout (rows AND columns)
- Use Flexbox for components, Grid for page layouts
A:
- Get the share link from Google Maps
- Convert it to embed format
- Use an iframe element with the embed URL
- Set width and height attributes
A: The footer uses CSS Grid to create a responsive layout. On desktop, it shows 4 columns. On mobile, it stacks vertically. The footer includes company info, links, contact details, and social media icons.
A: Use CSS properties like word-wrap: break-word, max-width: 100%, and box-sizing: border-box to ensure content stays within its container and doesn't break the layout.
- Experiment: Change colors, add content, modify layouts
- Practice: Complete the exercises above
- Build: Create your own project using these concepts
- Learn More: Explore advanced topics like:
- CSS Grid
- JavaScript frameworks (React, Vue)
- Backend development
- Database integration
Congratulations! You've learned the fundamentals of web development through this project. You now understand:
HTML structure and semantic markup CSS styling, layout, and responsive design JavaScript for interactivity Best practices and code organization
Keep practicing, building projects, and learning. Web development is a journey, and you're on the right path!
Happy Coding!
This project is for educational purposes. Feel free to use it as a learning resource.
Last Updated: 2025
Olives Technologies
- Address: Accra, Ghana
- Phone: +233 55 330 6360
- Email: olitech1010@gmail.com
- Google Maps: View Location
- Reviews: Leave a Review
BY CLEMENT OLIVES