All TalkersCode Topics

Follow TalkersCode On Social Media

Cool Image Hover Effects CSS

Last Updated : Jan 1, 2023

Cool Image Hover Effects CSS

In this tutorial we will show you the solution of cool image hover effects css, we will learn about using CSS how to make different effects when we hover on image.

As we know css used to style html elements, here we inserted image by using <img> element.

The ‘src’ attribute value contains path information of image and we defined another attribute ‘class’ to give different effects during hover.

Using pseudo class of ‘hover’ we defines shadow, border, opacity and blur properties to create different effects on any html elements.

Step By Step Guide On Cool Image Hover Effects CSS :-

We can implement styles using three types (i.e inline, external or internal) Internal means we have to define our style within <style> tag in head block and inline means we have use style within element definition, external means we defined our css at separate file with .css extension we have to import by <link> tag within head block.

Here we used internal style method and in our program we defined block of style properties to create different animations when we hover over the image in html webpage.

Here we inserted image four times using <img> tag with different classes for make four types of hover effects on image.

In first image when we hover on image it creates shadow effect, second image when we hover on that it creates border around image, third image when we hover on that it creates animation of pulse effect by using opacity and final image when we hover on that it makes blur effect.

<!DOCTYPE html>
        <title>COOL IMAGE HOVER</title>
            width: 30%;
            height: 10rem;
            box-shadow: 10px 10px 50px #555;
            width: 30%;
            height: 10rem;
            border: 5px solid green;
            border-radius: 10px 10px 10px 10px;
            width: 30%;
            height: 10rem;
            animation: ho 3s ease infinite;
        @keyframes ho{
            from{opacity: 0;}
            to{opacity: 1;}
            width: 30%;
            height: 10rem;
            filter: blur(4px);
        <img src="bg.jpg" class="one">
        <img src="bg.jpg" class="two">
        <img src="bg.jpg" class="three">
        <img src="bg.jpg" class="four">
  1. <!DOCTYPE html> tag which is instruct the web browser about what version of HTML file written in.
  2. The<html> tag is used to indicate the beginning of HTML document.
  3. As above shown <head> tag is containing information about webpage and if you need any external file those links are declared here. <title> tag is used for set the webpage title.
  4. Here we defined block of styles for create different types of hover effects. The ‘.one’ class will refers first image in body block within that what are we defines it will affects the image.
  5. Using class attribute values of ‘.one,.two,.third,.four’ we defines each image size by style property ‘width and height’.
  6. In each class with ‘:hover’ refers pseudo class of hover within that what we defines it will happen when we mouse over those images.
  7. In ‘.one:hover’ we defined box shadow around the image by using ‘box-shadow’ property and in ‘.two:hover’ we defined border with green color, curve edges. Then in ‘.three:hover’ we defined animation for 3sec infinite times and within animation we sets image initial opacity to ‘0’ and ends with opacity ‘1’.
  8. Here when we sets opacity to value ‘0’ image will invisible and value ‘1’ refers image visible so when we hover this image will animated like blink effect. In ‘.four:hover’ we makes image as blur for that we used ‘filter’ property with ‘blur’ value.
  9. Both <head> and <title> tags having their pair end tag, so we need to close the ending tags respectively. If you’re not closed anyone of ending tag properly that is also affect the webpage result.
  10. <body> tag is beginning of main coding part because it contain coding of entire website blocks and elements described here.
  11. Here we added same image four times with different class values to make different hover effects on each image and those all styles, hover effects as we seen earlier from point 4.
  12. Both </body>,</html> tags closed respectively. </body> tag indicates the end of body, Then </html> tag indicates the end of HTML document.

Conclusion :-

In conclusion we are able to know different types of hover effects we can make using css. When we hover on images each one will animated with different effects.

We can also create other effects like zoom-in, zoom-out or rotate,..etc.

We can’t define hover like style properties because ‘hover’ is a state or behavior when we mouse over to any html elements on webpage, so we have to define hover as a ‘pseudo’ class.

We can use hover effect on any html elements and within pseudo class we can also define different type of animations.

I hope this tutorial on cool image hover effects css helps you and the steps and method mentioned above are easy to follow and implement.

Latest Tutorials