E-commerce Website Using HTML, CSS, and JavaScript (Source Code)

E-commerce Website Using HTML, CSS, and JavaScript

Codewithashutosh
8 min readJan 29, 2024

Hello Coder, In this article, we are going to create an e-commerce website using HTML, CSS, and JavaScript with source code. This is a simple e-commerce website that has a product slider with images, a product section with a product card, and all the necessary features that e-commerce websites have.

Dear Coders: Let’s explore how to create an E-commerce website source code using HTML, CSS, and JavaScript. We use HTML code to build the foundation of an e-commerce website, and CSS code to style it. Every code is discussed in depth. Next, we leverage certain functionality from an e-commerce website, and to do this, we write JavaScript code.

What is an E-commerce Website?

An e-commerce website is an online or digital shopping complex from which users can order different types of items from the comfort of their homes. These online shopping websites let you select clothing 24/7, from electronics to food items; all things can be delivered to their homes.

What are the benefits of an E-commerce Website?

The benefits of an E-commerce website are:

  1. 24×7 customer support
  2. Different payment methods.
  3. Fully return policy.
  4. Delivery all over the world.

It’s time to move to your e-commerce website if you’re becoming tired of buying on Amazon, Flipkart, or any other e-commerce website and want to try something different.

100+ HTML,CSS and JavaScript Projects With Source Code ( Beginners to Advanced)

Hey, wait one second, you do not have your own website? Don’t feel bad; I am here to help you learn. How to build an e-commerce website, so stay connected to the blog till the end. Once you have your e-commerce website, do shopping as much as you want.

Let’s have a look at the website’s appearance before going into the process used to create it. You can browse my elegant online store.

Live Preview Online E-commerce Website Source Code:- Here you can check it.

After viewing my responsive e-commerce website plan, you likely already have an idea for your own website.

Ecommerce Website Code

The following skills are necessary for creating this webpage. They are the essential components you should possess for creating an e-commerce website:

1. HTML.
2. CSS.
3. Javascript(Basics).

HTML Code For E-commerce Website:-

The Skelton system (the frame/structure of bones) of the human body gives a structure/layout to the human body. Similarly, HTML code does the same it gives the layout of the websites.

Don’t worry you don’t need any biological knowledge for this website.

Restaurant Website Using HTML and CSS

Every webpage has three main sections:-
1.Header(Navigation bar/menu/logo,etc.)
2.Main section(main content).
3. Footer

1. Header:-

Below there is a picture of the navigation bar which contains the brand name/logo, search bar, and menu items, this all comes under the header.

1. In the header section, firstly make three divs. One for the logo, the second for the search bar, and the third for menu lists.

In the second class, I used the search icon I have imported through Ionicon, for any type of icon used in website development you can use it.

Gym Website Using HTML and CSS With Source Code

Input is a tag used for many purposes like checkboxes, radio, email input, date, time, and others. But here we are using for search bar so type is text. For more ideas, you can refer to our other blogs.

<header>
<div class="logo"><a href="#">ShoPperZ</a></div>
<div class="search">
<a href=""
><input type="text" placeholder="search products" id="input" />
<ion-icon class="s" name="search"></ion-icon>
</a>
</div>
<div class="heading">
<ul>
<li><a href="#" class="under">HOME</a></li>
<li><a href="#" class="under">SHOP</a></li>
<li><a href="#" class="under">OUR PRODUCTS</a></li>
<li><a href="#" class="under">CONTACT US</a></li>
<li><a href="#" class="under">ABOUT US</a></li>
</ul>
</div>
</header>

As our website should be Responsive(A Responsive website is automatically adjusted for different screen sizes and viewports.)

For Example:-Blogger website is also responsive you can easily use comfortably it on a phone(small screens) and PC(big-sized screens).

So when we are using the website there is a problem that it is not able to show all the menu lists on the navbar. Finally, we decided to make a button-operated menu list. So when you click on the menu icon It will open into a menu list which you can see in the next image.

10+ HTML CSS Projects For Beginners (Source Code)

You have seen how will solve the problem but now it’s time to code. Add a menu class in which a close icon you can see in the above image and also add a menu icon in the heading1 class.

<header>
<div class="logo"><a href="#">ShoPperZ</a></div>
<div class="menu">
<a href=""><ion-icon name="close" class="close"></ion-icon></a>
<ul>
<li><a href="#" class="under">HOME</a></li>
<li><a href="#" class="under">SHOP</a></li>
<li><a href="#" class="under">OUR PRODUCTS</a></li>
<li><a href="#" class="under">CONTACT US</a></li>
<li><a href="#" class="under">ABOUT US</a></li>
</ul>
</div>
<div class="search">
<a href=""
><input type="text" placeholder="search products" id="input" />
<ion-icon class="s" name="search"></ion-icon>
</a>
</div>
<div class="heading">
<ul>
<li><a href="#" class="under">HOME</a></li>
<li><a href="#" class="under">SHOP</a></li>
<li><a href="#" class="under">OUR PRODUCTS</a></li>
<li><a href="#" class="under">CONTACT US</a></li>
<li><a href="#" class="under">ABOUT US</a></li>
</ul>
</div>
<div class="heading1"><ion-icon name="menu" class="ham"></ion-icon></div>
</header>

Now, the header section is over. Let’s move forward to the main section.

2. Section:-

Section portion which mainly contains the content of a website is divided section mainly into two portions:-

section1 which contains an image-slider contains images. Section 2 which contains the container class contains different items.

Use the image tag to add various images to the image slider. Add a container named “class” inside Section 2 so that it inserts things named “classes” on your website as many times as you like. Add the item name, item price, item image, and item data classes to every item. You can also add one more category if you’d like.

<section>
<div class="section">
<div class="section1">
<div class="img-slider">
<img
src="https://images.pexels.com/photos/6347888/pexels-photo-6347888.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260"
alt=""
class="img"
/>
<img
src="https://images.pexels.com/photos/3962294/pexels-photo-3962294.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260"
alt=""
class="img"
/>
<img
src="https://images.pexels.com/photos/2292953/pexels-photo-2292953.jpeg?auto=compress&cs=tinysrgb&dpr=2&w=500"
alt=""
class="img"
/>
<img
src="https://images.pexels.com/photos/1229861/pexels-photo-1229861.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260"
alt=""
class="img"
/>
<img
src="https://images.pexels.com/photos/1598505/pexels-photo-1598505.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260"
alt=""
class="img"
/>
</div>
</div>
<div class="section2">
<div class="container">
<div class="items">
<div class="img img1">
<img
src="https://images.pexels.com/photos/1464625/pexels-photo-1464625.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"
alt=""
/>
</div>
<div class="name">SHOES</div>
<div class="price">$5</div>
<div class="info">
Lorem ipsum dolor sit amet consectetur.
</div>
</div>
<div class="items">
<div class="img img2">
<img
src="https://images.pexels.com/photos/3649765/pexels-photo-3649765.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"
alt=""
/>
</div>
<div class="name">MEN's T-SHIRT</div>
<div class="price">$6.34</div>
<div class="info">Lorem ipsum dolor sit.</div>
</div>
<div class="items">
<div class="img img3">
<img
src="https://media.istockphoto.com/photos/folded-blue-jeans-on-a-white-background-modern-casual-clothing-flat-picture-id1281304280"
alt=""
/>
</div>
<div class="name">JEANS</div>
<div class="price">$9</div>
<div class="info">Lorem ipsum dolor sit amet.</div>
</div>
<div class="items">
<div class="img img1">
<img
src="https://images.pexels.com/photos/8839887/pexels-photo-8839887.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"
alt=""
/>
</div>
<div class="name">WATCH</div>
<div class="price">$9.1</div>
<div class="info">Lorem ipsum dolor sit.</div>
</div>
<div class="items">
<div class="img img1">
<img
src="https://images.pexels.com/photos/6858618/pexels-photo-6858618.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"
alt=""
/>
</div>
<div class="name">SMART PHONE</div>
<div class="price">$20</div>
<div class="info">Lorem ipsum dolor sit.</div>
</div>
<div class="items">
<div class="img img1">
<img
src="https://images.pexels.com/photos/5552789/pexels-photo-5552789.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"
alt=""
/>
</div>
<div class="name">TELEVISION</div>
<div class="price">$18</div>
<div class="info">
Lorem ipsum dolor sit amet consectetur.
</div>
</div>
<div class="items">
<div class="img img1">
<img
src="https://images.pexels.com/photos/4295985/pexels-photo-4295985.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"
alt=""
/>
</div>
<div class="name">HOODIES</div>
<div class="price">$6.7</div>
<div class="info">Lorem ipsum dolor sit.</div>
</div>
<div class="items">
<div class="img img1">
<img
src="https://media.istockphoto.com/photos/vintage-plates-with-silver-teaspoons-picture-id184363070"
alt=""
/>
</div>
<div class="name">DINNER SET</div>
<div class="price">$10</div>
<div class="info">
Lorem ipsum dolor sit amet consectetur adipisicing elit.
</div>
</div>
<div class="items">
<div class="img img1">
<img
src="https://images.pexels.com/photos/6463348/pexels-photo-6463348.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"
alt=""
/>
</div>
<div class="name">BLANKETS</div>
<div class="price">$9.9</div>
<div class="info">
Lorem ipsum dolor sit amet consectetur adipisicing.
</div>
</div>
<div class="items">
<div class="img img1">
<img
src="https://images.pexels.com/photos/2659939/pexels-photo-2659939.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"
alt=""
/>
</div>
<div class="name">LAPTOP</div>
<div class="price">$99</div>
<div class="info">
Lorem ipsum dolor sit amet consectetur, adipisicing
elit.
</div>
</div>
<div class="items">
<div class="img img1">
<img
src="https://media.istockphoto.com/photos/modern-kitchen-microwave-oven-picture-id1144960519"
alt=""
/>
</div>
<div class="name">MICROWAVE</div>
<div class="price">$30</div>
<div class="info">
Lorem ipsum dolor sit amet consectetur, adipisicing
elit.
</div>
</div>
<div class="items">
<div class="img img1">
<img
src="https://media.istockphoto.com/photos/black-coffee-maker-with-green-led-lights-picture-id177395430"
alt=""
/>
</div>
<div class="name">COFFEE MAKER</div>
<div class="price">$29.7</div>
<div class="info">
Lorem ipsum dolor sit amet consectetur, adipisicing
elit.
</div>
</div>
<div class="items">
<div class="img img1">
<img
src="https://images.pexels.com/photos/6606354/pexels-photo-6606354.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"
alt=""
/>
</div>
<div class="name">BED</div>
<div class="price">$100</div>
<div class="info">
Lorem ipsum dolor sit amet consectetur, adipisicing
elit.
</div>
</div>
<div class="items">
<div class="img img1">
<img
src="https://media.istockphoto.com/photos/woman-turning-on-air-conditioner-picture-id1325708905"
alt=""
/>
</div>
<div class="name">AIR CONDITIONER</div>
<div class="price">$78</div>
<div class="info">
Lorem ipsum dolor sit amet consectetur, adipisicing
elit.
</div>
</div>
<div class="items">
<div class="img img1">
<img
src="https://images.pexels.com/photos/5834/nature-grass-leaf-green.jpg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"
alt=""
/>
</div>
<div class="name">BOOK</div>
<div class="price">$9</div>
<div class="info">
Lorem ipsum dolor sit amet consectetur, adipisicing
elit.
</div>
</div>
<div class="items">
<div class="img img1">
<img
src="https://images.pexels.com/photos/4339598/pexels-photo-4339598.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"
alt=""
/>
</div>
<div class="name">BAG</div>
<div class="price">$36.5</div>
<div class="info">
Lorem ipsum dolor sit amet consectetur, adipisicing
elit.
</div>
</div>
<div class="items">
<div class="img img1">
<img
src="https://media.istockphoto.com/photos/hand-of-a-lady-selecting-yellow-colored-saree-in-a-shop-picture-id1301740530"
alt=""
/>
</div>
<div class="name">SAREES</div>
<div class="price">$25.6</div>
<div class="info">
Lorem ipsum dolor sit amet consectetur, adipisicing
elit.
</div>
</div>
<div class="items">
<div class="img img1">
<img
src="https://images.pexels.com/photos/5816934/pexels-photo-5816934.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"
alt=""
/>
</div>
<div class="name">WASHING MACHINE</div>
<div class="price">$56</div>
<div class="info">
Lorem ipsum dolor sit amet consectetur, adipisicing
elit.
</div>
</div>
</div>
</div>
</div>
</section>

The section part is over.

Notation: Hey Are you still wondering why we assigned a class name to this tag? The correct response is that it will support you in styling it. The answer is no if you wish to style several tags with the same styling, in which case you would need to style each tag separately.
Simply giving each tag the same name will cause all tags with that name to be styled when a style is applied to one class.

Tic Tac Toe Game Using HTML,CSS and JavaScript

3. Footer:-

Footer is the last section of the website. In which add some details. The Footer of the above website is shown below in the picture.

Now how we are going to implement it??

Hope the above picture will help you to understand how to implement it. Firstly, Divide the footer into main 4 classes namely footer0, footer1, footer2, and footer3.

Now it’s time to implement its code.

Creating Christmas Tree With Pure Css

Inside the footer1 class, add one class for social media icons, then inside add their icons.

Similarly, add more classes in footer2 and footer3 as given below in the code.

read more and get complete source code

--

--

Codewithashutosh

My name is Ashutosh Mishra, subscribe our telegram channel for free complete source code, https://t.me/codewithashutosh