Introduction

This tutorial will dive into a fun and creative web design effect – the Glowing Bulb Effect. If you want to add an interactive and visually stunning feature to your website, this is the perfect project. You’ll learn how to create this glowing effect using nothing but HTML and CSS, so there’s no need for JavaScript or complicated scripting.

This effect is perfect for anyone experimenting with CSS animations, transitions, and basic HTML structure to create dynamic, engaging visuals on their site. Whether you’re building a personal project, a portfolio, or adding flair to a business site, the glowing bulb effect will impress your visitors.

What is a Glowing Bulb Effect in HTML and CSS?

The Glowing Bulb Effect is a visual effect where a bulb image appears to glow, creating a dynamic lighting effect on your webpage. This effect simulates a light turning on and off by toggling between pictures of a glowing bulb and a standard bulb. This is achieved purely with HTML and CSS, making it a lightweight, fast-loading feature that doesn’t require JavaScript or other external libraries.

This tutorial will walk you through the steps to create this effect from scratch. You can control the bulb’s glowing state with a simple button click, providing an interactive experience for your users.

Why Should You Use the Glowing Bulb Effect?

There are many reasons why you might want to add a glowing bulb effect to your site:

  1. Visual Appeal: This effect adds a touch of elegance and creativity to your website, making it stand out from others.
  2. User Engagement: With the toggle effect, users can interact with the site, making the experience more engaging.
  3. Simple and Lightweight: Since this effect uses only HTML and CSS, it’s easy to implement, and the page will load quickly without relying on heavy scripts.
  4. Customization: You can adjust the effect to fit your site’s theme, making it as subtle or bold as you prefer.

What You’ll Need

To get started with creating the glowing bulb effect, you’ll need the following:

  • Basic knowledge of HTML and CSS: You don’t need to be an expert; you need to be comfortable working with the basics.
  • Two images: One for the bulb in its “off” state and one for the glowing “on” state.
  • A simple button to toggle between the two states.

Setting Up Your Files

First, create two files: one for your HTML and another for your CSS. Let’s go over the structure.

1. HTML Structure

The HTML will set up the basic structure for the bulb and the button that controls the glow effect. Here’s the code you’ll need for the index.html file:

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
  <meta charset="utf-8">
  <title>Glowing Bulb Effect | Abhikesh Kumar</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <div class="wrapper">
    <input type="checkbox" id="btn">
    <img id="bulb-off" src="bulb-off.png">
    <img id="bulb-on" src="bulb-on.png">
    <label for="btn" class="btn">
      <span></span>
    </label>
  </div>
</body>
</html>

This HTML code sets up a container for the bulb image and a button to toggle the bulb’s state. The src for the image starts with the “off” bulb, and the button will update the bulb’s state when clicked.

2. CSS Styling

Next, we’ll create the styling to add the glowing effect to the bulb. Create a file named style.css and paste the following CSS:

@import url('https://fonts.googleapis.com/css?family=Poppins:400,500,600,700&display=swap');
*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Poppins', sans-serif;
}
body{
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #111;
}
.wrapper{
  width: 450px;
  height: 500px;
  position: relative;
}
img{
  margin-top: -50px;
  height: 450px;
  width: 100%;
  position: absolute;
}
img#bulb-on{
  opacity: 0;
  animation: glow 3s linear infinite;
}
@keyframes glow {
  0%{
    opacity: 1;
  }
  5%{
    opacity: 1;
  }
  70%{
    opacity: 1;
  }
  74%{
    opacity: 0;
  }
  80%{
    opacity: 1;
  }
  84%{
    opacity: 0;
  }
  90%{
    opacity: 1;
  }
  100%{
    opacity: 1;
  }
}
.btn{
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}
.btn span{
  height: 50px;
  width: 180px;
  display: block;
  text-align: center;
  line-height: 48px;
  background:none;
  color: #fff;
  text-transform: uppercase;
  font-size: 20px;
  cursor: pointer;
  border: 2px solid #fff;
  border-radius: 5px;
  transition: all 0.3s ease;
}
.btn span:hover{
  background: #fff;
  color: #111;
}
#btn:checked ~ .btn span{
  background: #fff;
  color: #111;
}
.btn span:before{
  content: "Turn Off";
}
#btn:checked ~ img#bulb-on{
  animation: none;
}
#btn:checked ~ .btn span:before{
  content: "Turn on";
}
.wrapper input{
  display: none;
}

Explanation of CSS:

  • The #bulb selector adjusts the size of the bulb image.
  • The glow animation applies a glowing effect when the bulb is “on” (indicated by bulb-on.png).
  • The @keyframes rule gradually increases the bulb’s brightness, creating a glowing effect.

Conclusion

Now that you’ve set up the HTML and CSS for your Glowing Bulb Effect, you can easily toggle the bulb’s state with a button click. This effect is lightweight, engaging, and easy to implement, making it a perfect addition to your website.

To expand this effect, you can modify the glowing brightness, add additional animations, or even change the bulb’s color for more variation.

Want to Check Username Availability on Social Media?If you’re looking to check username availability on various social media platforms, visit NameChkr to find out!
Read Also

  1. Glassmorphism Login Form in HTML and CSS
    Explore the stylish world of glassmorphism as you create a modern login form using HTML and CSS. This guide breaks down the design process step by step.
  2. Toggle Button using HTML, CSS, and JavaScript
    Discover how to enhance user interaction by creating a sleek toggle button with HTML, CSS, and JavaScript. This tutorial covers everything from structure to styling.
  3. Responsive Cards in HTML and CSS
    Learn how to design eye-catching responsive cards that adapt seamlessly to any device. This guide offers practical tips for achieving stunning layouts.
  4. Build a Google Gemini Chatbot Using HTML, CSS, and JS
    Dive into chatbot development by creating a Google Gemini chatbot with HTML, CSS, and JavaScript. This tutorial will help you understand the basics of interactive forms.

Download Source Code

To get started quickly, you can download the complete source code for this project. Click the download button below, extract the files, and you’ll be all set!

By mastering simple HTML and CSS techniques like this, you can unlock a whole new world of interactive, dynamic effects for your website.

Leave a Reply

Your email address will not be published. Required fields are marked *