- First, create a folder with any name you like. Then, put the necessary files inside it.
- Create a file called
index.html
to serve as the main file. - Create a file called
style.css
for the CSS code.
In this project we will create basic design for Amazon web page clone. Design will be made with plain html and plain css with help of google fonts.
First create index.html page and copy paste below code
Understanding an HTML Template for an Amazon Clone
In this tutorial, we will explore a detailed HTML template designed to resemble an Amazon product listing and main page interface. This template includes several components such as a header with navigation, search functionality, and a footer with links, which are crucial for a functional e-commerce website.
1. Basic Structure
The HTML document starts with the declaration of document type <!DOCTYPE html>
which is an instruction to the web browser about the version of HTML the page is written in. The html
element follows, with lang="en"
attribute specifying the language of the page content.
2. Head Section
The <head>
section contains metadata, links to external stylesheets, and other resources necessary for the layout and styling of the page:
- Character Set and Viewport:
<meta charset="UTF-8">
specifies the character encoding for the webpage.<meta name="viewport" content="width=device-width, initial-scale=1.0">
makes the webpage responsive by setting the viewport to scale based on the device’s width. - Title:
<title>Amazon Website Clone || DevTechTutor</title>
sets the title of the webpage as seen in the browser tab. - Stylesheets: External CSS files are linked to control the presentation of the HTML elements. This example uses Google Fonts for icons.
3. Body Section
The <body>
section contains all content visible to the user:
- Header and Navigation:
- Logo: A clickable logo image inside a
<div>
with a classnav-logo
. - Delivery Information: A delivery option with location icon using
material-symbols-outlined
. - Search Bar: Combines a dropdown for categories and a text input for search queries.
- Sign-In and Cart Information: Areas for user interaction like signing in and viewing the cart.
- Logo: A clickable logo image inside a
- Banner and Navigation Links: Below the top navigation, a banner possibly for promotions and additional navigation links like “Today’s Deals” or “Customer Service” enhance user navigation and engagement.
4. Main Content
- Hero Section: A placeholder section potentially for a large promotional image or slider.
- Shopping Section: Displays product categories with images and shopping links. Each category (
shop-link
) includes a title, an image, and a call-to-action link.
5. Footer
The footer is structured into multiple columns, each containing lists of links that help users find more information about the company, connect on social media, explore money-making opportunities with Amazon, and receive assistance. This is typical of e-commerce sites aiming to provide comprehensive resources at the bottom of the page.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Amazon Website Clone || DevTechTutor</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200">
</head>
<body>
<header>
<nav class="navbar">
<div class="nav-logo">
<a href="#"><img src="images/amazon_logo.png" alt="logo"></a>
</div>
<div class="address">
<a href="#" class="deliver">Deliver</a>
<div class="map-icon">
<span class="material-symbols-outlined">location_on</span>
<a href="#" class="location">Rijeka</a>
</div>
</div>
<div class="nav-search">
<select class="select-search">
<option>All</option>
<option>All Categories</option>
<option>Amazon Devices</option>
</select>
<input type="text" placeholder="Search Amazon" class="search-input">
<div class="search-icon">
<span class="material-symbols-outlined">search</span>
</div>
</div>
<div class="sign-in">
<a href="#"> <p>Hello, sign in</p>
<span>Account & Lists</span></a>
</div>
<div class="returns">
<a href="#"><p>Returns</p>
<span>& Orders</span></a>
</div>
<div class="cart">
<a href="#">
<span class="material-symbols-outlined cart-icon">shopping_cart</span>
</a>
<p>Cart</p>
</div>
</nav>
<div class="banner">
<div class="banner-content">
<div class="panel">
<span class="material-symbols-outlined">menu</span>
<a href="#">All</a>
</div>
<ul class="links">
<li><a href="#">Today's Deals</a></li>
<li><a href="#">Customer Service</a></li>
<li><a href="#">Registry</a></li>
<li><a href="#">Gift Cards</a></li>
<li><a href="#">Sell</a></li>
</ul>
<div class="deals">
<a href="#">Shop deals in Electronics</a>
</div>
</div>
</div>
</header>
<section class="hero-section"></section>
<section class="shop-section">
<div class="shop-images">
<div class="shop-link">
<h3>Shop Laptops & Tables</h3>
<img src="images/img-1.png" alt="card">
<a href="#">Shop now</a>
</div>
<div class="shop-link">
<h3>Shop Smartwatches</h3>
<img src="images/img-2.png" alt="card">
<a href="#">Shop now</a>
</div>
<div class="shop-link">
<h3>Create with Strip Lights</h3>
<img src="images/img-3.png" alt="card">
<a href="#">Shop now</a>
</div>
<div class="shop-link">
<h3>Home Refresh Ideas</h3>
<img src="images/img-4.png" alt="card">
<a href="#">Shop now</a>
</div>
</div>
</section>
<footer>
<a href="#" class="footer-title">
Back to top
</a>
<div class="footer-items">
<ul>
<h3>Get to Know Us</h3>
<li><a href="#">About us</a></li>
<li><a href="#">Careers</a></li>
<li><a href="#">Press Release</a></li>
<li><a href="#">Amazon Science</a></li>
</ul>
<ul>
<h3>Connect with Us</h3>
<li><a href="#">Facebook</a></li>
<li><a href="#">Twitter</a></li>
<li><a href="#">Instagram</a></li>
</ul>
<ul>
<h3>Make Money with Us</h3>
<li><a href="#">Sell on Amazon</a></li>
<li><a href="#">Sell under Amazon Accelerator</a></li>
<li><a href="#">Protect and Build Your Brand</a></li>
<li><a href="#">Amazon Global Selling</a></li>
<li><a href="#">Become an Affiliate</a></li>
<li><a href="#">Fulfillment by Amazon</a></li>
<li><a href="#">Advertise Your Products</a></li>
<li><a href="#">Amazon Pay on Merchants</a></li>
</ul>
<ul>
<h3>Let Us Help You</h3>
<li><a href="#">COVID-19 and Amazon</a></li>
<li><a href="#">Your Account</a></li>
<li><a href="#">Return Centre</a></li>
<li><a href="#">100% Purchase Protection</a></li>
<li><a href="#">Amazon App Download</a></li>
<li><a href="#">Help</a></li>
</ul>
</div>
</footer>
</body>
</html>
2. CSS design of HTML skeleton
First create style.css page which is then directly connected to above index.html.
Explanation of each part of design is included in this snippet code in the greyed out comments section
These comments will help you understand how specific properties affect elements and why certain values are chosen.
Global Styles
*
: The universal selector targets all elements on the page. It resets margins and padding to zero and sets thebox-sizing
toborder-box
, which includes padding and border in the element’s total width and height. This makes layout management easier and more predictable. The font family ‘Open Sans’ is applied globally, ensuring a consistent typography across the website.html
: Thescroll-behavior: smooth;
property allows for a smooth scrolling effect when navigating to different parts of the webpage through anchor links.
Links
a
: All links (<a>
tags) have no text decoration and a white (#fff
) color to maintain a clean look. On hover, the color changes to a lighter shade (#ddd
), providing visual feedback that the link is interactive.
Header and Navbar
Structure: The
.navbar
class styles the navigation bar, displaying its elements in a row (flex
), center-aligned, and spaced between. Themax-width
property limits its width, centering it within the parent container.Logo:
.nav-logo img
styles the logo image, setting its top margin and width.Address and Search Bar: The
.address
and.nav-search
classes style the delivery options and the search functionality, respectively. The search bar is designed to be prominent and user-friendly with a dedicated button styled with a different background color for the search icon.
Interactive Elements
- Search Dropdown and Input: The
.select-search
and.search-input
are styled to appear seamless with no borders and background colors that match or complement each other. The search button (search-icon
) uses a contrast color (#febd68
) making it stand out for better user interaction.
Banner and Main Navigation Links
- The
.banner
styles the secondary navigation area or promotional banner with padding and background color. The.banner-content
contains layout styling for any content within the banner.
Main Content Styles
Hero Section: The
.hero-section
is designed to showcase a prominent image or carousel with a set height, background image, and covering properties ensuring the image fills the designated space effectively.Product Display (Shop Section): This section uses CSS Grid to arrange product images responsively. Each product link (
shop-link
) is styled with a background, padding, and a flex layout to organize its content vertically.
Footer
- The footer is divided into sections using
.footer-title
for the top clickable link and.footer-items
for the detailed link lists. These sections use different background colors and font styles to differentiate them visually from the rest of the page.
/* Importing Open Sans font from Google Fonts with various weights for typography versatility */
@import url("https://fonts.googleapis.com/css2?family=Open+Sans:wght@200;300;400;500;600;700&display=swap");
/* Global settings */
* {
margin: 0; /* Remove default margin from all elements */
padding: 0; /* Remove default padding from all elements */
box-sizing: border-box; /* Include padding and border in the width and height of all elements */
font-family: "Open Sans", sans-serif; /* Set a consistent font family throughout the site */
}
/* Enhance link navigation smoothness on click */
html {
scroll-behavior: smooth;
}
/* Link styles */
a {
text-decoration: none; /* Remove underline from links */
color: #fff; /* Set link color to white */
}
/* Change link color on hover to a light gray for visual feedback */
a:hover {
color: #ddd;
}
/* Header styles */
header {
width: 100%; /* Ensure header spans full width of the viewport */
background-color: #0f1111; /* Dark background for the header */
}
/* Navbar container */
.navbar {
display: flex; /* Use flexbox for layout */
align-items: center; /* Center items vertically */
justify-content: space-between; /* Distribute space between items */
cursor: pointer; /* Indicate clickable items */
color: #fff; /* White text color for readability */
max-width: 1280px; /* Maximum width of navbar */
margin: 0 auto; /* Center navbar horizontally */
}
/* Logo styles */
.nav-logo img {
margin-top: 10px; /* Space above the logo */
width: 128px; /* Set fixed width for the logo */
}
/* Delivery section styles */
.address .deliver {
margin-left: 20px; /* Space to the left of the deliver element */
font-size: 0.75rem; /* Smaller font size for the text */
color: #ccc; /* Light gray color for text */
}
/* Address icon and text alignment */
.address .map-icon {
display: flex; /* Use flexbox for layout */
align-items: center; /* Align items vertically in the center */
}
/* Search bar container */
.nav-search {
display: flex; /* Use flexbox for layout */
justify-content: space-evenly; /* Distribute space evenly among children */
max-width: 620px; /* Maximum width of the search bar */
width: 100%; /* Full width of the container */
height: 40px; /* Fixed height for the search bar */
border-radius: 4px; /* Rounded corners */
}
/* Search select dropdown styling */
.select-search {
background: #f3f3f3; /* Light gray background */
width: 50px; /* Width of the dropdown */
text-align: center; /* Center text horizontally */
border-top-left-radius: 4px; /* Rounded top-left corner */
border-bottom-left-radius: 4px; /* Rounded bottom-left corner */
border: none; /* No border */
}
/* Search input field styling */
.search-input {
max-width: 600px; /* Maximum width */
width: 100%; /* Full width */
font-size: 1rem; /* Size of text */
border: none; /* No border */
outline: none; /* Remove outline on focus */
padding-left: 10px; /* Padding inside the input field */
}
/* Search icon styling */
.search-icon {
max-width: 45px; /* Maximum width */
width: 100%; /* Full width */
display: flex; /* Use flexbox for layout */
justify-content: center; /* Center content horizontally */
align-items: center; /* Center content vertically */
font-size: 1.2rem; /* Icon size */
background: #febd68; /* Background color */
color: #000; /* Text color */
cursor: pointer; /* Indicate clickable item */
border-top-right-radius: 4px; /* Rounded top-right corner */
border-bottom-right-radius: 4px; /* Rounded bottom-right corner */
}
/* Sign-in and returns text styling */
.sign-in p, .returns p {
font-size: 0.75rem; /* Smaller font size */
}
.sign-in,
.returns span {
font-size: 0.875rem; /* Slightly larger font size */
font-weight: 600; /* Bold text for emphasis */
}
/* Cart icon and text styling */
.cart {
display: flex; /* Use flexbox for layout */
}
.cart .cart-icon {
font-size: 2.5rem; /* Large size for the cart icon */
}
.cart p {
margin-top: 20px; /* Margin above the text */
font-weight: 500; /* Medium font weight */
}
/* Styling for the banner */
.banner {
padding: 10px 20px; /* Padding around content */
background: #222f3d; /* Darker background for contrast */
color: #fff; /* White text for readability */
font-size: 0.875rem; /* Text size */
}
.banner-content {
margin: 0 auto; /* Center content horizontally */
max-width: 1280px; /* Maximum width */
display: flex; /* Use flexbox for layout */
align-items: center; /* Align items vertically */
justify-content: space-between; /* Distribute space between items */
}
.panel {
display: flex; /* Use flexbox for layout */
align-items: center; /* Align items vertically */
gap: 5px; /* Space between items */
cursor: pointer; /* Indicate clickable items */
}
.panel span {
margin-right: 7px; /* Space to the right of the icon */
}
.links {
display: flex; /* Use flexbox for layout */
align-items: center; /* Align items vertically */
list-style: none; /* Remove default list styling */
gap: 15px; /* Space between links */
flex-grow: 1; /* Allow the list to fill space */
margin-left: 15px; /* Space to the left of the list */
}
.links a {
padding: 10px 0; /* Padding above and below links */
}
.deals a {
font-size: 0.9rem; /* Text size */
font-weight: 500; /* Medium font weight */
white-space: nowrap; /* Prevent text wrapping */
}
/* Hero Section Styles */
.hero-section {
height: 400px; /* Set fixed height for visual impact and consistency */
background-image: url("images/hero-img.jpg"); /* Background image for hero section */
background-position: center; /* Center the background image */
background-size: cover; /* Ensure the image covers the entire section, cropping if necessary */
}
/* Shop Section Styles */
.shop-section {
display: flex; /* Use flexbox to align children vertically in a column */
align-items: center; /* Center items horizontally */
flex-direction: column; /* Stack children elements vertically */
background-color: #f3f3f3; /* Light gray background for the section, enhances readability */
padding: 50px 0; /* Vertical padding for spacing around content */
}
/* Grid layout for product images, responsive to varying screen sizes */
.shop-images {
display: grid; /* Grid layout for placing children elements in a matrix */
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); /* Create as many columns as fit, minimum width of 250px */
gap: 40px; /* Space between grid items */
max-width: 1280px; /* Maximum width of the grid */
width: 100%; /* Full width to utilize available space */
}
/* Individual product link styling */
.shop-link {
background-color: #fff; /* White background for each product block */
padding: 30px; /* Padding around the content */
display: flex; /* Use flexbox for layout */
cursor: pointer; /* Indicate that the block is clickable */
flex-direction: column; /* Organize content vertically */
white-space: nowrap; /* Prevent text wrapping */
}
/* Product images */
.shop-link img {
width: 100%; /* Full width to expand to the container's width */
height: 280px; /* Fixed height for images */
object-fit: cover; /* Ensure the image covers the space without distorting */
margin-bottom: 10px; /* Space below the image */
}
/* Product titles */
.shop-link h3 {
margin-bottom: 10px; /* Space below the title */
}
/* Links within shop-link */
.shop-link a {
display: inline-block; /* Make link block-level but inline for styling */
margin-top: 10px; /* Space above the link */
font-size: 0.9rem; /* Slightly smaller font size */
color: blue; /* Blue color for links, traditional for web */
font-weight: 500; /* Medium font weight for emphasis */
transition: color 0.3s ease; /* Smooth transition for color change on hover */
}
/* Hover effect for links */
.shop-link:hover a {
color: #c7511f; /* Change color on hover to provide feedback */
text-decoration: underline; /* Underline to indicate it's clickable */
}
/* Footer Styles */
.footer-title {
display: flex; /* Use flexbox for layout */
align-items: center; /* Center items vertically */
justify-content: center; /* Center items horizontally */
background-color: #37475a; /* Dark blue background for contrast */
color: #fff; /* White text for readability */
font-size: 0.875rem; /* Standard font size for footer titles */
font-weight: 600; /* Bold text for emphasis */
height: 60px; /* Fixed height for uniform appearance */
}
/* Footer link container */
.footer-items {
display: flex; /* Use flexbox to distribute space among children */
justify-content: space-evenly; /* Even spacing between columns */
width: 100%; /* Full width to use available space */
margin: 0 auto; /* Center horizontally */
background: #232f3e; /* Dark background for footer */
}
/* Footer headings */
.footer-items h3 {
font-size: 1rem; /* Slightly larger font size for visibility */
font-weight: 500; /* Medium font weight for clarity */
color: #fff; /* White text for contrast */
margin: 20px 0 10px 0; /* Margins for spacing around headings */
}
/* Footer links list */
.footer-items ul {
list-style: none; /* Remove default list style */
margin-bottom: 20px; /* Space below each list */
}
/* Footer links */
.footer-items li a {
color: #ddd; /* Light gray for text, less contrast than white */
font-size: 0.875rem; /* Standard font size for footer links */
}
/* Hover effect for footer links */
.footer-items li a:hover {
text-decoration: underline; /* Underline on hover for visual feedback */
}