FINDING YOUR DIRECTION

0%
← Scrollhaus Journal

Website Animation Guides · Published · Updated · 5 min read

CSS Border Glow Effect: A Copyable Hover and Focus Style

A small border glow can direct attention to one important card or action without adding a heavy animation library.

Published by Amanjot Singh, founder of Scrollhaus. AI-assisted editorial work; product context, sources and corrections are documented in our editorial methodology.

Violet and pink illuminated rectangular frame above dark stone
Scrollhaus Journal · Website Animation Guides

A CSS border glow can make one card or call to action feel active without drawing attention away from the page. The useful version is restrained, appears on hover or keyboard focus, and keeps the text readable. You do not need JavaScript or a heavy animation package for a simple glowing border.

Copy a glowing border in CSS

This example keeps a quiet outline at rest. Hovering a pointer or moving keyboard focus inside the panel strengthens the border and shadow. The link remains a real HTML link with its normal focus behavior.

<div class="glow-panel">
  <h2>See the collection</h2>
  <a href="/websites/">Explore websites</a>
</div>
<style>
.glow-panel {
  padding: 24px;
  color: #f7f4ff;
  background: #151320;
  border: 1px solid #5d5275;
  border-radius: 18px;
  box-shadow: 0 0 0 1px rgba(183,156,255,.08),
              0 0 18px rgba(150,110,230,.12);
  transition: border-color .25s, box-shadow .25s;
}
.glow-panel:hover, .glow-panel:focus-within {
  border-color: #b79cff;
  box-shadow: 0 0 0 1px rgba(183,156,255,.3),
              0 0 26px rgba(150,110,230,.25);
}
@media (prefers-reduced-motion: reduce) {
  .glow-panel { transition: none; }
}
</style>

Adjust the glow colour to your brand but keep it distinct from the panel background. The border provides an edge even when a browser or device renders the shadow softly. Because the glow is decorative, the link label and focus state still need to be understandable without it.

Where a border glow belongs

Use it to emphasize one product option, a featured pricing card or a primary action. Avoid applying the same bright effect to every card: if everything glows, nothing has priority. For a page with video or a moving background, use an even quieter outline so the two layers do not compete.

When to animate the glow

A slow, continuous pulse can be appropriate for a short campaign scene. It is less useful for a form, checkout or reading-heavy page, where repeated movement distracts. If you add a loop, provide a way to pause it where required, honor reduced-motion preferences and check CPU and battery use on a phone. A hover transition is often enough.

Large blurred shadows are expensive when many elements animate at once. Keep the shadow radius modest and animate only one or two panels. Test the initial, hover and keyboard-focus states in both light and dark themes. A CSS border animation that looks clean on a static screenshot can become noisy when placed over moving footage.

Glowing gradient border with a pseudo-element

A box-shadow gives a single-color outer glow. For a glowing gradient border, draw the gradient on a pseudo-element behind the element and blur a copy of it. This CSS border animation rotates the gradient through 360deg, so the animated glowing edge appears to travel around the card.

@property --angle { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
.glow-card { position: relative; border-radius: 16px; background-color: #0b0b12; }
.glow-card::before, .glow-card::after {
content: ""; position: absolute; inset: -2px; z-index: -1;
border-radius: inherit; pointer-events: none;
background: conic-gradient(from var(--angle), #7c5cff, #22d3ee, #7c5cff);
animation: spin 4s linear infinite;
}
.glow-card::after { filter: blur(18px); opacity: 0.7; }
@keyframes spin { to { --angle: 360deg; } }

The parent needs position: relative; and each layer position: absolute; with border-radius: inherit; so the glow follows the corners. If you want a transparent centre, use a real border instead: set border: 2px solid transparent and two backgrounds, one clipped to the padding-box and the gradient clipped to the border-box.

Inner glow and outer glow with box-shadow

For an inner glow, add the inset keyword: box-shadow: inset 0 0 12px rgba(124, 92, 255, 0.6). Combine it with a normal shadow for an outer glow on hover. Both are cheap to render and need no extra div in the HTML.

Tailwind CSS version

In Tailwind CSS, the same glow effect uses utility classes: relative rounded-2xl on the card and before:absolute before:inset-0 before:rounded-2xl before:blur-lg for the layer, with the gradient and animation defined in your CSS file. Similar border animations, such as a pulsing glow or a moving beam, change only the keyframes.

Reduced motion

Respect prefers-reduced-motion. A common web development reset stops the rotation while keeping the static glowing border:

@media (prefers-reduced-motion: reduce) {
.glow-card::before, .glow-card::after {
animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important;
}
}

Common fixes

For related motion patterns, see the Scrollhaus effects collection, the cursor effects guide and the website animations guide. CSS references: MDN box-shadow and MDN focus-within.

Frequently asked questions

How do I make a border glow in CSS?

Combine a visible border with one or two restrained box shadows. Strengthen the colour and shadow on hover and focus-within.

Does a glowing border need JavaScript?

No. A static, hover or focus-responsive CSS border glow needs no JavaScript.

Why is my glow cut off?

A parent with overflow hidden can clip the outer shadow. Leave space around the panel or adjust the parent layout.

Browse Scrollhaus website designs and build resources →

Need help with a template, account, or project? Email admin@scrollhaus.ai.