{"id":1173,"date":"2025-03-08T13:17:08","date_gmt":"2025-03-08T13:17:08","guid":{"rendered":"https:\/\/codebox.keyframetechsolution.com\/?p=1173"},"modified":"2025-04-05T05:35:26","modified_gmt":"2025-04-05T05:35:26","slug":"rainbow-gradient-border","status":"publish","type":"post","link":"https:\/\/codebox.keyframetechsolution.com\/rainbow-gradient-border\/","title":{"rendered":"Create Rainbow Gradient Border Animation Using HTML CSS Only"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p><span data-preserver-spaces=\"true\">In modern web design, animations are a great way to add dynamic effects to your website. <\/span><span data-preserver-spaces=\"true\">In this<\/span><span data-preserver-spaces=\"true\"> tutorial<\/span><span data-preserver-spaces=\"true\">, <\/span><span data-preserver-spaces=\"true\">we&#8217;ll<\/span><span data-preserver-spaces=\"true\"> show you how to create a <strong>rainbow gradient border<\/strong> using only <\/span>HTML<span data-preserver-spaces=\"true\"> and <\/span>CSS<span data-preserver-spaces=\"true\">.<\/p>\n<p><\/span><span data-preserver-spaces=\"true\"> Before writing the code, <\/span><span data-preserver-spaces=\"true\">let&#8217;s<\/span><span data-preserver-spaces=\"true\"> first understand what it is.<\/span><\/p>\n<p>\u2705\u00a0<strong>Watch Live Preview<\/strong>\u00a0\ud83d\udc49\ud83d\udc49<\/p>\n<p><iframe title=\"YouTube video player\" src=\"https:\/\/www.youtube.com\/embed\/hftko5pZpug?si=mVfBKhcOi039nwtO\" width=\"100%\" height=\"450\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p><a href=\"#conclusion\">Click Here to Download the Code<\/a><\/p>\n<div class=\"border-blog-highlight\">\n<h3>Table of Contents<\/h3>\n<ul>\n<li><a href=\"#section1\">What is Gradient Border in CSS?<\/a><\/li>\n<li><a href=\"#section2\">Set Up Project<\/a><\/li>\n<li><a href=\"#section3\">HTML Code Structure<\/a><\/li>\n<li><a href=\"#section4\">CSS Code Structure<\/a><\/li>\n<li><a href=\"#conclusion\">Conclusion<\/a><\/li>\n<\/ul>\n<\/div>\n<h2 id=\"section1\"><span data-preserver-spaces=\"true\">What is Gradient Border in CSS?<\/span><\/h2>\n<p><span data-preserver-spaces=\"true\">It is a border that transitions between colors, creating a smooth gradient effect. Instead of using a single color for the border, you can apply a gradient (a smooth transition from one color to another) around an element, making the border look more dynamic and visually interesting. <\/span><\/p>\n<p><span data-preserver-spaces=\"true\">This effect is achieved using CSS gradients and can be customized with different colors and directions. Let\u2019s break down the process step-by-step.<\/span><\/p>\n<p><strong>Similar Posts:<\/strong> <a href=\"https:\/\/codebox.keyframetechsolution.com\/border-animation-html-css\/\">How to Create Border Animation using HTML and CSS<\/a><\/p>\n<h3 id=\"section2\"><strong><span data-preserver-spaces=\"true\">Set Up Project<\/span><\/strong><\/h3>\n<p><span data-preserver-spaces=\"true\">Start by creating a folder on your computer for your project. Inside this folder, create the following files:<\/span><\/p>\n<ul>\n<li><strong><span data-preserver-spaces=\"true\">index.html<\/span><\/strong><\/li>\n<li><strong><span data-preserver-spaces=\"true\">style.css<\/span><\/strong><\/li>\n<\/ul>\n<h2>Source code<\/h2>\n<h3 id=\"section3\">HTML Code Structure<\/h3>\n<p><span data-preserver-spaces=\"true\">Before <\/span><span data-preserver-spaces=\"true\">we dive<\/span><span data-preserver-spaces=\"true\"> into CSS, <\/span><span data-preserver-spaces=\"true\">let\u2019s<\/span> <span data-preserver-spaces=\"true\">first<\/span><span data-preserver-spaces=\"true\"> set up the basic HTML structure.<\/span><\/p>\n<div class=\"code-container\">\n<div class=\"toolbar\">\n<div class=\"actions\">\n        <span><\/span><br \/>\n        <span class=\"yellow\"><\/span><br \/>\n        <span class=\"green\"><\/span>\n      <\/div>\n<div class=\"title\">index.html<\/div>\n<\/div>\n<div class=\"code-content\">\n<pre><code class=\"language-markup\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"en\"&gt;\r\n&lt;head&gt;\r\n  &lt;meta charset=\"UTF-8\"&gt;\r\n  &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;\r\n  &lt;title&gt;Rainbow Gradient Border Animation Using CSS Only | Rainbow Border CSS&lt;\/title&gt;\r\n  &lt;link rel=\"stylesheet\" href=\"style.css\"&gt;\r\n  &lt;link rel=\"stylesheet\" href=\"https:\/\/fonts.googleapis.com\/css2?family=Comfortaa:wght@600&display=swap\"&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\r\n&lt;!-- CODE --&gt;\r\n\r\n&lt;div class=&quot;gradient-border&quot;&gt;Rainbow Gradient Border Animation&lt;\/div&gt;\r\n\r\n&lt;!-- CODE END --&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<h3 id=\"section4\">CSS Code Structure<\/h3>\n<p>Next, let&#8217;s start by styling the content box. We&#8217;ll add some padding and set a background color for the inner area.<\/p>\n<div class=\"code-container\">\n<div class=\"toolbar\">\n<div class=\"actions\">\n        <span><\/span><br \/>\n        <span class=\"yellow\"><\/span><br \/>\n        <span class=\"green\"><\/span>\n      <\/div>\n<div class=\"title\">style.css<\/div>\n<\/div>\n<div class=\"code-content\">\n<pre><code class=\"language-markup\">\r\n&lt; \/* Your CSS code here *\/ &gt;\r\nhtml, body {\r\n\theight: 100%;\r\n}\r\n\r\nbody {\r\n\tdisplay: flex;\r\n\tjustify-content: center;\r\n\talign-items: center;\r\n\theight: 100%;\r\n\tbackground: #000;\r\n}\r\n\r\n.gradient-border {\r\n\twidth: 450px;\r\n\theight: 250px;\r\n\tcolor: white;\r\n\tfont-size: 40px;\r\n\tline-height: 60px;\r\n\tbackground: #000;\r\n\tposition: relative;\r\n\tborder-radius: 5px;\r\n\tdisplay: flex;\r\n\talign-items: center;\r\n\tjustify-content: center;\r\n\ttext-align: center;\r\n\tfont-family: 'Comfortaa', cursive;\r\n}\r\n\r\n.gradient-border:after {\r\n\tcontent: '';\r\n\tposition: absolute;\r\n    height: 270px;\r\n    width: 470px;\r\n\tbackground: linear-gradient(60deg, #f79533, #f37055, #ef4e7b, #a166ab, #5073b8, #1098ad, #07b39b, #6fba82);\r\n\tborder-radius: 5px;\r\n\t-webkit-animation: animatedgradient 3s ease alternate infinite;\r\n\tanimation: animatedgradient 3s ease alternate infinite;\r\n\tbackground-size: 300% 300%;\r\n\tz-index: -1;\r\n}\r\n\r\n@-webkit-keyframes animatedgradient {\r\n\t0% {\r\n\t\tbackground-position: 0% 50%;\r\n\t}\r\n\t50% {\r\n\t\tbackground-position: 100% 50%;\r\n\t}\r\n\t100% {\r\n\t\tbackground-position: 0% 50%;\r\n\t}\r\n}\r\n\r\n@keyframes animatedgradient {\r\n\t0% {\r\n\t\tbackground-position: 0% 50%;\r\n\t}\r\n\t50% {\r\n\t\tbackground-position: 100% 50%;\r\n\t}\r\n\t100% {\r\n\t\tbackground-position: 0% 50%;\r\n\t}\r\n}\r\n      <\/code><\/pre>\n<\/div>\n<\/div>\n<p><strong>You May Also Like:<\/strong><\/p>\n<p><a href=\"https:\/\/codebox.keyframetechsolution.com\/animated-login-signup-form\/\">Animated Login and Signup Form using HTML CSS and JavaScript<\/a><\/p>\n<p><a href=\"https:\/\/codebox.keyframetechsolution.com\/circular-carousel-slider-html-css\/\">Animated Circular Carousel\/Slider using HTML and CSS only<\/a><\/p>\n<h2 id=\"conclusion\"><span data-preserver-spaces=\"true\">Conclusion<\/span><\/h2>\n<p><span data-preserver-spaces=\"true\">In this tutorial, we have created an animated gradient border.<\/span><span data-preserver-spaces=\"true\"> By leveraging <a href=\"https:\/\/cssgradient.io\/\" rel=\"nofollow noopener\" target=\"_blank\">CSS gradients<\/a> and <a href=\"https:\/\/www.joshwcomeau.com\/animation\/keyframe-animations\/\" rel=\"nofollow noopener\" target=\"_blank\">keyframe animations<\/a>, we have achieved a dynamic border effect that <\/span><span data-preserver-spaces=\"true\">can be applied<\/span><span data-preserver-spaces=\"true\"> to any element on your webpage.<\/span><\/p>\n<p><span data-preserver-spaces=\"true\">Feel free to experiment with different color combinations, timings, and hover effects to customize it to your needs.<\/span><\/p>\n<p><span data-preserver-spaces=\"true\">This technique is lightweight, performs efficiently, and adds a modern touch to your website without relying on JavaScript or external libraries.<\/span><\/p>\n<p><strong><i class=\"fa fa-download\" style=\"color:#046bd2;\"><\/i> 35 people downloaded this<\/strong><br \/>\n<strong>Get It FREE Now<\/strong><\/p>\n<div class=\"download-code\">\n<a href=\"https:\/\/codebox.keyframetechsolution.com\/wp-content\/uploads\/2025\/01\/Rainbow-Gradient-Border-Animation.zip\">Download Source Code<\/a>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction In modern web design, animations are a great way to add dynamic effects to your website. In this tutorial, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1174,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"footnotes":""},"categories":[88,377],"tags":[460,461,463,462],"class_list":["post-1173","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-designs","category-free-source-code","tag-gradient-border","tag-gradient-border-animation-css","tag-rainbow-gradient-border-css","tag-rainbow-gradient-css"],"acf":[],"_links":{"self":[{"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/posts\/1173","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/comments?post=1173"}],"version-history":[{"count":13,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/posts\/1173\/revisions"}],"predecessor-version":[{"id":1892,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/posts\/1173\/revisions\/1892"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/media\/1174"}],"wp:attachment":[{"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/media?parent=1173"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/categories?post=1173"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/tags?post=1173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}