Introduction
Celebrating national festivals like Republic Day digitally can be fun and engaging! In this tutorial, we will create a stunning animated web page using just HTML and CSS. The page features a creative greeting message with gradient text effects to display “HAPPY REPUBLIC DAY” in the colors of the Indian flag, styled for an eye-catching appeal.
Below is the code and explanation to create this design.
HTML Code:
<div class="container"> <span>HAPPY</span> <h1>REPUBLIC</h1> <span>DAY</span> </div>
CSS Code:
body { background-color: #000000; /* Black background for strong contrast */ margin: 0; height: 100vh; display: flex; align-items: center; justify-content: center; } .container { text-align: center; /* Centers text within the container */ } h1 { color: transparent; /* Ensures text color is invisible by default */ font-family: "Poppins", sans-serif; /* Modern and clean font */ background: linear-gradient( #ffa500 0, /* Orange for the top 40% */ #ffa500 40%, #ffffff 40%, /* White in the middle section */ #ffffff 60%, #00ff00 60%, /* Green for the bottom section */ #00ff00 100% ); font-size: 6.25em; /* Large font for the word REPUBLIC */ -webkit-background-clip: text; /* Clips background to text for effect */ background-clip: text; -webkit-text-stroke: 0.01em #ffffff; /* Thin white stroke around letters */ } span { font-size: 6.25em; /* Matches the size of REPUBLIC */ -webkit-text-stroke: 0.05em #ffffff; /* Thicker white outline */ color: #ffffff; /* Visible white text for HAPPY and DAY */ font-family: "Poppins", sans-serif; }
Code Explanation
- HTML Structure
- The
<div>
with the classcontainer
holds the text elements (<span>
for “HAPPY” and “DAY,” and<h1>
for “REPUBLIC”). - Each text element is styled to be visually striking and aligned at the center.
- The
- CSS Styling
- Body:
A black background creates a sleek contrast for the vibrant text. - Gradient Effect:
The gradient on “REPUBLIC” transitions through the saffron (#FFA500), white (#FFFFFF), and green (#00FF00) colors of the Indian flag. - Text Styling:
-webkit-background-clip: text;
ensures the gradient is visible only through the text.-webkit-text-stroke
adds an outline to enhance readability.
- Body:
Why This Design Works
The design emphasizes simplicity and impact. The bright colors of the Indian flag against a black background draw immediate attention. The balanced typography ensures the message is clear and festive.
- How to implement gradient text effects in CSS.
- Tips for creating responsive, centered layouts.
- Best practices for clean and structured code.
Celebrate this Republic Day by sharing your own version of this project and spreading patriotic vibes online!
Download Code