Inward Shadow Hover Effect using HTML and CSS

Share your love

In the dynamic world of web design, the smallest details can make a big impact on user experience. One subtle yet effective way to add depth and interactivity to your website is through hover effects. Among these, the inward shadow hover effect stands out for its elegance and sophistication.

In this blog post, we’ll embark on a journey to implement the inward shadow hover effect using only HTML and CSS. By harnessing the power of these core web technologies, we’ll unlock the secrets to adding depth and visual interest to your web elements.

I would recommend you don’t just copy and paste the code, just look at the code and type by understanding it.


See the Pen Inward Shadow Pt. 2 by Smashing Magazine (@smashingmag) on CodePen.

HTML Code 

Starter Template

<!doctype html>
<html lang="en">

    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSS -->
    <link rel="stylesheet" href="style.css">

    <title>Inward Shadow Hover Effect using HTML and CSS - Coding Torque</title>

    <!-- Further code here -->

    <script src="script.js"></script>


Paste the below code in your <body> tag.

	<h3>Overlay using shadows &mdash; bring the cursor over one of the circles</h3>
	<div class=item><span>The New York Times</span></div>
	<div class=item><span>The Washington Post</span></div>
	<div class=item><span>Los Angeles Times</span></div>

CSS Code 

Create a file style.css and paste the code below.

		inset var(--itemWidthMinus) var(--itemWidthMinus) 0 black, 
		inset var(--itemWidth) var(--itemWidthMinus) 0 green, 
		inset var(--itemWidthMinus) var(--itemWidth) 0 blue, 
		inset var(--itemWidth) var(--itemWidth) 0 yellow, 
		0 0 20px silver;
	transition: box-shadow ease-in-out .6s, color ease-in-out .5s;	
	width: var(--itemWidth);
	height: var(--itemWidth);
	border-radius: 50%;
	text-align: center;
	background: center/50%  no-repeat;
	cursor: pointer;
	display: grid;
	color: white;
	font-size: calc(var(--itemWidth) / 7);
	grid-row:  2 / 3;
		inset 0 0 0 transparent, 
		inset 0 0 0 transparent, 
		inset 0 0 0 transparent, 
		inset 0 0 0 transparent, 
		0 0 20px silver;
	color: transparent;
	--itemWidth: min(300px, 30vw);
	--itemWidthMinus: calc(-1 * var(--itemWidth));
	height: max-content;
	width: max-content;
	display: grid;
	grid-template-rows: repeat(2, max-content);
	grid-template-columns: repeat(3, calc(3vw + var(--itemWidth)));
	font-family: 'Averia Serif Libre';
	background-image: url(;
	background-image: url(;
	background-image: url(;
.item > span {
	width: 80%;
	user-select: none; -moz-user-select: none; -webkit-user-select: none;
	grid-row: 1 / 2;
	grid-column: 1 / 4;
	height: 80px;
	width: 90vw;
	text-align: center;
body * { place-self: center;}
body {
	display: grid;
	height: 100vh;

Final Output

Written by: Piyush Patil

Code Credits:

If you found any mistakes or have any doubts please feel free to Contact Us

Hope you find this post helpful💖

Share your love