Ecommerce Website Using HTML, CSS, and JavaScript (Source Code)
Published: 2023-05-09 04:27:40

Hello Coder, In this Article we are Going to create E-commerce Website Using HTML, CSS, and JavaScript with Code. This is a Simple [E-commerce Website](https://www.codewithrandom.com/2023/03/15/ecommerce-website-using-html-css-and-javascript-simple-and-responsive-ecommerce-website/) that has a Product slider with images, a Product section with 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.

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.

Heyy....., wait one second did you have not your website? Don't feel bad, I am here to help you to make you learn How to build an e-commerce website so stay connected to the blog till the end at the end, you have your e-commerce website then do shopping as so 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.





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

Coding Language Used	Name of Coding language
1	HTML
2	CSS
3	JAVASCRIPT

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 Online Shopping 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.

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

1. Header:-
            
1. In the header section, firstly made 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.




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.
You have seen how will solve the problem but now it's time to code. 
```
<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.




3. Footer:-
Footer is the last section of the website. In which add some details. 

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.
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.
```
<footer>
    <div class="footer0"><h1>ShoPperZ</h1></div>
    <div class="footer1">
        Connect with us at
        <div class="social-media">
            <a href="#"> <ion-icon name="logo-facebook"></ion-icon> </a>
            <a href="#"> <ion-icon name="logo-linkedin"></ion-icon> </a>
            <a href="#"> <ion-icon name="logo-youtube"></ion-icon> </a>
            <a href="#"> <ion-icon name="logo-instagram"></ion-icon> </a>
            <a href="#"> <ion-icon name="logo-twitter"></ion-icon> </a>
        </div>
    </div>
    <div class="footer2">
        <div class="product">
            <div class="heading">Products</div>
            <div class="div">Sell your Products</div>
            <div class="div">Advertise</div>
            <div class="div">Pricing</div>
            <div class="div">Product Buisness</div>
        </div>
        <div class="services">
            <div class="heading">Services</div>
            <div class="div">Return</div>
            <div class="div">Cash Back</div>
            <div class="div">Affiliate Marketing</div>
            <div class="div">Others</div>
        </div>
        <div class="Company">
            <div class="heading">Company</div>
            <div class="div">Complaint</div>
            <div class="div">Careers</div>
            <div class="div">Affiliate Marketing</div>
            <div class="div">Support</div>
        </div>
        <div class="Get Help">
            <div class="heading">Get Help</div>
            <div class="div">Help Center</div>
            <div class="div">Privacy Policy</div>
            <div class="div">Terms</div>
            <div class="div">Login</div>
        </div>
    </div>
    <div class="footer3">
        Copyright ©
        <h4>ShoPperZ</h4>
        2021-2028
    </div>
</footer>

```
<-----Now, HTML code ends---->




Ecommerce Website Source Code
Now it's time to add CSS and JAVASCRIPT files to the HTML.So As I am using the external file for the CSS and JAVASCRIPT so I linked it in the HTML code.
```
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
        <link rel="stylesheet" href="./ecommerce.css" />
        <link
            href="https://unpkg.com/ionicons@4.5.10-0/dist/css/ionicons.min.css"
            rel="stylesheet"
        />
    </head>
    <body>
        <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>
        <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>
        <footer>
            <div class="footer0"><h1>ShoPperZ</h1></div>
            <div class="footer1">
                Connect with us at
                <div class="social-media">
                    <a href="#"> <ion-icon name="logo-facebook"></ion-icon> </a>
                    <a href="#"> <ion-icon name="logo-linkedin"></ion-icon> </a>
                    <a href="#"> <ion-icon name="logo-youtube"></ion-icon> </a>
                    <a href="#">
                        <ion-icon name="logo-instagram"></ion-icon>
                    </a>
                    <a href="#"> <ion-icon name="logo-twitter"></ion-icon> </a>
                </div>
            </div>
            <div class="footer2">
                <div class="product">
                    <div class="heading">Products</div>
                    <div class="div">Sell your Products</div>
                    <div class="div">Advertise</div>
                    <div class="div">Pricing</div>
                    <div class="div">Product Buisness</div>
                </div>
                <div class="services">
                    <div class="heading">Services</div>
                    <div class="div">Return</div>
                    <div class="div">Cash Back</div>
                    <div class="div">Affiliate Marketing</div>
                    <div class="div">Others</div>
                </div>
                <div class="Company">
                    <div class="heading">Company</div>
                    <div class="div">Complaint</div>
                    <div class="div">Careers</div>
                    <div class="div">Affiliate Marketing</div>
                    <div class="div">Support</div>
                </div>
                <div class="Get Help">
                    <div class="heading">Get Help</div>
                    <div class="div">Help Center</div>
                    <div class="div">Privacy Policy</div>
                    <div class="div">Terms</div>
                    <div class="div">Login</div>
                </div>
            </div>
            <div class="footer3">
                Copyright ©
                <h4>ShoPperZ</h4>
                2021-2028
            </div>
        </footer>
        <script src="https://unpkg.com/ionicons@4.5.10-0/dist/ionicons.js"></script>
        <script src="./ecommerce.js"></script>
    </body>
</html>

```
so the structure of our website is ready.


CSS Code For Online Shopping Website:-

The structure of the website layout is completed but it doesn't look good without styling. Human skeletal alone can't look good without skin. So here the work of styling is done with the help of  CSS.

Topics to be known before the CSS tutorial:-

1. Flexbox.
2.CSS basics(selectors,color,border-box,etc).
3.pseduo effects(hover, active) and pseudo elements(before).
4.media queries(responsive) and keyframes(animation).  

1. Firstly style the header. Use the Flex property to align every flex item in the header in a line.
then use the same for the search menu and heading lists as flexbox. then align them in a  horizontal line using properties.
2. set the visibility of the menu class and heading class to be hidden because it should appear when the size of the screen is less. (when we are using it on phones or tab).


3. Apply other properties and hover effects(the HOVER effect works when the cursor goes over the tag on which it is applied) to the header files as shown below.
4. Using the keyframe property which is used for the animation (I use it for the image slider).
5. Apply styling on the items/products and their classes (flex and some other properties).
6. Similarly, apply some styling on the Footer as shown below.


7. Finally when your webpage is ready now it's time to make it responsive so that it also works fine on small screens(phones).
8. Use the media queries property to make it responsive and inside it mention the properties you want to see when the size of a screen is small.
finally, check your website is ready.
```
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
header {
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  height: 60px;
  width: 100%;
  background: black;
}
.heading ul {
  display: flex;
}
.logo a {
  color: white;
  transition-duration: 1s;
  font-weight: 800;
}
.logo a:hover {
  color: rgb(240, 197, 6);
  transition-duration: 1s;
}
.heading ul li {
  list-style: none;
}
.heading ul li a {
  margin: 5px;
  text-decoration: none;
  color: black;
  font-weight: 500;
  position: relative;
  color: white;
  margin: 2px 14px;
  font-size: 18px;
  transition-duration: 1s;
}
.heading ul li a:active {
  color: red;
}
.heading ul li a:hover {
  color: rgb(243, 168, 7);
  transition-duration: 1s;
}

.heading ul li a::before {
  content: "";
  height: 2px;
  width: 0px;
  position: absolute;
  left: 0;
  bottom: 0;
  background-color: white;
  transition-duration: 1s;
}
.heading ul li a:hover::before {
  width: 100%;
  transition-duration: 1s;
  background-color: rgb(243, 168, 7);
}
#input {
  height: 30px;
  width: 300px;
  text-decoration: none;
  border: 0px;
  padding: 5px;
}
.logo a {
  color: white;
  font-size: 35px;
  font-weight: 500;
  text-decoration: none;
}
ion-icon {
  width: 30px;
  height: 30px;
  background-color: white;
  color: black;
}
ion-icon:hover {
  cursor: pointer;
}
.search a {
  display: flex;
}
header a ion-icon {
  position: relative;
  right: 3px;
}

.img-slider img {
  height: 720px;
  width: 1080px;
}
@keyframes slide {
  0% {
    left: 0px;
  }
  15% {
    left: 0px;
  }
  20% {
    left: -1080px;
  }
  32% {
    left: -1080px;
  }
  35% {
    left: -2160px;
  }
  47% {
    left: -2160px;
  }
  50% {
    left: -3240px;
  }
  63% {
    left: -3240px;
  }
  66% {
    left: -4320px;
  }
  79% {
    left: -4320px;
  }
  82% {
    left: -5400px;
  }
  100% {
    left: 0px;
  }
}
.img-slider {
  display: flex;
  float: left;
  position: relative;
  width: 1080px;
  height: 720px;
  animation-name: slide;
  animation-duration: 10s;
  animation-iteration-count: infinite;
  transition-duration: 2s;
}

.heading1 {
  opacity: 0;
}
.search {
  display: flex;
  position: relative;
}
.section1 {
  width: 1080px;
  overflow: hidden;

  justify-content: center;
  align-items: center;
  margin: 0px auto;
}

.section2 .container {
  display: flex;
  width: 100%;
  height: max-content;
  flex-wrap: wrap;
  justify-content: center;
  margin: 10px auto;
}
.section2 .container .items {
  margin: 10px;
  width: 200px;
  height: 300px;
  background-color: white;
  border: 2.5px solid black;
  border-radius: 12px;
}
.section2 .container .items .name {
  text-align: center;
  background-color: rgb(240, 197, 6);
  height: 25px;
  padding-top: 4px;
  color: white;
  margin: 0;
}
.section2 .container .items .price {
  float: left;
  padding-left: 10px;
  display: block;
  width: 100%;
  color: rgb(255, 0, 0);
  font-weight: 650;
}
.section2 .container .items .info {
  padding-left: 10px;
  color: rgb(243, 168, 7);
}
.section2 .container .items .img img {
  width: 200px;
  height: 200px;
  margin: 0;
  padding: 0;
  border-radius: 12px;
  transition-duration: 0.8s;
}
.section2 .container .items .img {
  overflow: hidden;
  margin: 0;
}
.section2 .container .items:hover .img img {
  transform: scale(1.2);
  transition-duration: 0.8s;
  border-radius: 12px;
}
footer {
  display: flex;
  flex-direction: column;
  background-color: black;
  align-items: center;
  color: white;
}

.footer1 {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: white;
  margin-top: 15px;
}
.social-media {
  display: flex;
  justify-content: center;
  color: white;
  flex-wrap: wrap;
}
.social-media a {
  color: white;
  margin: 20px;
  border-radius: 5px;
  margin-top: 10px;
  color: white;
}
.social-media a ion-icon {
  color: white;
  background-color: black;
}
.social-media a:hover ion-icon {
  color: red;
  transform: translateY(5px);
}
.footer2 {
  display: flex;
  width: 100%;
  justify-content: space-evenly;
  align-items: center;
  text-decoration: none;
  flex-wrap: wrap;
}
.footer0 {
  font-weight: 1200;
  transition-duration: 1s;
}
.footer0:hover {
  color: rgb(243, 168, 7);
}
.footer2 .heading {
  font-weight: 900;
  font-size: 18px;
}
.footer3 {
  margin-top: 60px;
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}
.footer2 .heading:hover {
  color: rgb(243, 168, 7);
}
.footer2 .div:hover {
  transform: scale(1.05);
}
.footer3 h4 {
  margin: 0 10px;
}
.footer2 div {
  margin: 10px;
}
.menu {
  visibility: hidden;
}
.heading1 .ham:active {
  color: red;
}
.items {
  overflow: hidden;
}
.ham,
.close {
  cursor: pointer;
}

@media screen and (max-width: 1250px) {
  .heading ul li {
    display: none;
  }

  .items {
    transform: scale(0.9);
  }
  .img-slider img {
    height: 60vw;
    width: 80vw;
  }
  .ham:active {
    color: red;
  }
  .menu {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .menu a ion-icon {
    position: absolute;
  }

  @keyframes slide1 {
    0% {
      left: 0vw;
    }
    15% {
      left: 0vw;
    }
    20% {
      left: -80vw;
    }
    32% {
      left: -80vw;
    }
    35% {
      left: -160vw;
    }
    47% {
      left: -160vw;
    }
    50% {
      left: -240vw;
    }
    63% {
      left: -240vw;
    }
    66% {
      left: -320vw;
    }
    79% {
      left: -320vw;
    }
    82% {
      left: -400vw;
    }
    100% {
      left: 0vw;
    }
  }
  .menu ul {
    display: flex;
    flex-direction: column;
    position: absolute;
    width: 100vw;
    height: 100vh;
    background-color: black;
    left: 0;
    top: 0;
    z-index: 11;
    align-items: center;
    justify-content: center;
    opacity: 1;
  }
  .close {
    z-index: 34;

    color: white;
    background-color: black;
  }
  .close:active {
    color: red;
  }
  .menu ul li {
    list-style: none;
    margin: 20px;
    border-top: 3px solid white;
    width: 80%;
    text-align: center;

    padding-top: 10px;
  }
  .menu ul li a {
    text-decoration: none;
    padding-top: 10px;
    color: white;
    font-weight: 900;
  }
  .menu ul li a:hover {
    color: rgb(240, 197, 6);
  }
  .img-slider {
    display: flex;
    float: left;
    position: relative;
    width: 80%;
    height: 60%;
    animation-name: slide1;
    animation-duration: 10s;
    animation-iteration-count: infinite;
    transition-duration: 2s;
  }
  .section1 {
    width: 80%;
    overflow: hidden;

    justify-content: center;
    align-items: center;
    margin: 0px auto;
  }

  .heading1 {
    opacity: 1;
    position: relative;
    bottom: 8px;
  }
  .search a {
    display: flex;
    flex-wrap: nowrap;
  }

  .heading1 .ham {
    background-color: black;
    color: white;
  }
  #input {
    width: 200px;
    flex-shrink: 2;
  }
  header {
    height: 150px;
  }
}
@media screen and (max-width: 550px) {
  .heading ul li {
    display: none;
  }
  .heading1 {
    opacity: 1;

    bottom: 8px;
  }

  header {
    height: 250px;
    flex-wrap: wrap;
    display: flex;
    flex-direction: column;
  }
  #input {
    width: 150px;
  }
  .close {
    z-index: 34;
  }

  .search a {
    display: flex;
    flex-wrap: nowrap;
  }
}


```
Heyyy......... wait one more second! what you said is your website is not working properly when the size of the screen is small. You can not able to open the menu list.
we will solve this problem using Javascript. So, Let's move on to the Javascript portion.

JavaScript Code for E-commerce Website:-

A website with only structure and styling is like a person is sleeping (It can't perform any functions). So for the well functioning of the website we use Javascript.

Topics you should know before implementing javascript code:-

1. DOM (Document Object Model) Manipulation.
2. Javascript basics.

So firstly we want that when we click on the menu icon shown in the below first image then the menu list should be opened as shown in the next figure and when we click on the close icon then again we are back to the first page as shown in the first figure.

The idea is clear now it's time to implement it in code.
```
1: const close=document.querySelector(".close"); 2: const
open=document.querySelector(".ham"); 3: const
menu=document.querySelector(".menu") 4: close.addEventListener("click",()=>{ 5:
menu.style.visibility="hidden"; 6: }) 7: open.addEventListener("click",()=>{ 8:
menu.style.visibility="visible"; 9: })

```
Firstly I selected the close, ham, and menu-named classes using the query selector.

then use the addEventListener(a function that allows us to run functions when certain events are performed).



I chose the click event for both close class and ham class so when you click on the icons of close and menu it will perform the code written inside that function which is supposed to run.


When we click on the close icon it sets the visibility of the menu class to be hidden (this makes the code written inside the menu class to be hidden means they are not going to run anymore.)


When we click on the menu icon(ham class) it sets the visibility of the menu list to visible(so now we can see the code snippet running that is written inside the menu class).


<---------Finally, a Simple and Responsive E-commerce website using HTML, CSS, and the Basics of Javascript is completed--------->
  
I hope you have liked your [E-commerce Website](https://www.codewithrandom.com/2023/03/15/ecommerce-website-using-html-css-and-javascript-simple-and-responsive-ecommerce-website/) Code Wait, Did you still not implement it So why are you waiting, go and implement it now and enjoy your shopping.


If you faced any difficulty feel free to comment on your problems and If you really liked it, please show your love in the comment section this really motivates a blogger to provide more such content.


Thank You For visiting!!!