<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: jacky</title>
    <description>The latest articles on DEV Community by jacky (@jacky112232).</description>
    <link>https://dev.to/jacky112232</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2076214%2F6ece4053-a744-4e4e-9e2f-b8f26e054aec.png</url>
      <title>DEV Community: jacky</title>
      <link>https://dev.to/jacky112232</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jacky112232"/>
    <language>en</language>
    <item>
      <title>How to Create a Single Page Coupon Website (with Full Code)</title>
      <dc:creator>jacky</dc:creator>
      <pubDate>Sun, 15 Sep 2024 15:09:35 +0000</pubDate>
      <link>https://dev.to/jacky112232/how-to-create-a-single-page-coupon-website-with-full-code-4f3m</link>
      <guid>https://dev.to/jacky112232/how-to-create-a-single-page-coupon-website-with-full-code-4f3m</guid>
      <description>&lt;h2&gt;
  
  
  What is a Coupon Website?
&lt;/h2&gt;

&lt;p&gt;A coupon website is a platform that allows users to find and apply promotional codes or discounts for various online or in-store purchases. It aggregates available coupons, offering users a simple way to save on their purchases.&lt;/p&gt;

&lt;h2&gt;
  
  
  Technologies Required
&lt;/h2&gt;

&lt;p&gt;To build a functional single-page &lt;a href="https://www.getdealshive.com/" rel="noopener noreferrer"&gt;coupon website&lt;/a&gt;, we will utilize the following technologies:&lt;/p&gt;

&lt;p&gt;HTML: To structure the page and its elements.&lt;br&gt;
CSS: To design and style the page.&lt;br&gt;
JavaScript: To add interactivity, such as filtering coupons or handling clicks.&lt;br&gt;
Optional: Basic knowledge of deploying via GitHub Pages or a similar platform.&lt;/p&gt;
&lt;h2&gt;
  
  
  Setting Up the Project
&lt;/h2&gt;

&lt;p&gt;Folder Structure&lt;br&gt;
Start by creating the following folder structure:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;coupon-website/&lt;br&gt;
│&lt;br&gt;
├── index.html&lt;br&gt;
├── styles.css&lt;br&gt;
└── script.js&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;index.html: This file will hold the structure of your website.&lt;br&gt;
styles.css: This will contain all the styling rules.&lt;br&gt;
script.js: This file will handle any interactivity for the website.&lt;br&gt;
File Preparation&lt;br&gt;
Once you've created the folders, you can start coding each file. We'll go through this step by step, starting with the HTML structure.&lt;/p&gt;
&lt;h2&gt;
  
  
  HTML Code for the Coupon Website
&lt;/h2&gt;

&lt;p&gt;Your index.html file will be the core structure of the coupon site. Below is the HTML code you can use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Coupon Deals&amp;lt;/title&amp;gt;
    &amp;lt;link rel="stylesheet" href="styles.css"&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;!-- Header Section --&amp;gt;
    &amp;lt;header&amp;gt;
        &amp;lt;h1&amp;gt;Welcome to Coupon Deals&amp;lt;/h1&amp;gt;
        &amp;lt;p&amp;gt;Find the best deals and save money today!&amp;lt;/p&amp;gt;
    &amp;lt;/header&amp;gt;

    &amp;lt;!-- Main Section with Coupon Listings --&amp;gt;
    &amp;lt;main&amp;gt;
        &amp;lt;section class="coupons"&amp;gt;
            &amp;lt;article class="coupon" data-expiry="2024-12-31"&amp;gt;
                &amp;lt;h2&amp;gt;20% Off on Electronics&amp;lt;/h2&amp;gt;
                &amp;lt;p&amp;gt;Use code: &amp;lt;span class="code"&amp;gt;SAVE20&amp;lt;/span&amp;gt;&amp;lt;/p&amp;gt;
                &amp;lt;button class="copy-code"&amp;gt;Copy Code&amp;lt;/button&amp;gt;
                &amp;lt;p class="expiry-date"&amp;gt;Expires: Dec 31, 2024&amp;lt;/p&amp;gt;
            &amp;lt;/article&amp;gt;

            &amp;lt;article class="coupon" data-expiry="2024-09-30"&amp;gt;
                &amp;lt;h2&amp;gt;Free Shipping on Orders Over $50&amp;lt;/h2&amp;gt;
                &amp;lt;p&amp;gt;Use code: &amp;lt;span class="code"&amp;gt;FREESHIP&amp;lt;/span&amp;gt;&amp;lt;/p&amp;gt;
                &amp;lt;button class="copy-code"&amp;gt;Copy Code&amp;lt;/button&amp;gt;
                &amp;lt;p class="expiry-date"&amp;gt;Expires: Sep 30, 2024&amp;lt;/p&amp;gt;
            &amp;lt;/article&amp;gt;

            &amp;lt;!-- Add more coupon articles here --&amp;gt;
        &amp;lt;/section&amp;gt;
    &amp;lt;/main&amp;gt;

    &amp;lt;!-- Footer Section --&amp;gt;
    &amp;lt;footer&amp;gt;
        &amp;lt;p&amp;gt;&amp;amp;copy; 2024 Coupon Deals. All rights reserved.&amp;lt;/p&amp;gt;
    &amp;lt;/footer&amp;gt;

    &amp;lt;script src="script.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  CSS Code for Styling
&lt;/h2&gt;

&lt;p&gt;Next, style the website using CSS. This will ensure the page looks clean, modern, and responsive. Here's the basic styles.css file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* Basic reset for consistent styling */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f4f4f4;
    color: #333;
    padding: 20px;
}

/* Header Styling */
header {
    text-align: center;
    padding: 20px 0;
    background-color: #4CAF50;
    color: white;
}

header h1 {
    font-size: 2.5rem;
}

header p {
    font-size: 1.2rem;
}

/* Main Section Styling */
main {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.coupons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.coupon {
    background-color: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s;
}

.coupon:hover {
    transform: scale(1.05);
}

.coupon h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.coupon p {
    font-size: 1rem;
    margin: 10px 0;
}

.copy-code {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
}

.copy-code:hover {
    background-color: #45a049;
}

.expiry-date {
    font-size: 0.9rem;
    color: #888;
}

/* Footer Styling */
footer {
    text-align: center;
    margin-top: 40px;
    font-size: 0.9rem;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  JavaScript for Interactivity
&lt;/h2&gt;

&lt;p&gt;For interactivity, we’ll use JavaScript to handle features like copying coupon codes and managing expiration dates. Here's the script.js file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;document.querySelectorAll('.copy-code').forEach(button =&amp;gt; {
    button.addEventListener('click', function() {
        const couponCode = this.previousElementSibling.textContent;
        navigator.clipboard.writeText(couponCode).then(() =&amp;gt; {
            alert('Coupon code copied: ' + couponCode);
        });
    });
});

// Highlight expired coupons
const currentDate = new Date();
document.querySelectorAll('.coupon').forEach(coupon =&amp;gt; {
    const expiryDate = new Date(coupon.getAttribute('data-expiry'));
    if (expiryDate &amp;lt; currentDate) {
        coupon.style.opacity = '0.5';
        coupon.querySelector('.expiry-date').textContent += ' (Expired)';
    }
});

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Functionality:&lt;/p&gt;

&lt;p&gt;Copy Coupon Code: When the user clicks the "Copy Code" button, the coupon code is copied to their clipboard, and an alert is displayed.&lt;br&gt;
Coupon Expiration: Coupons that have passed their expiration date are grayed out, and the word "Expired" is appended to their expiry date.&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
