{"id":144,"date":"2024-05-18T03:08:31","date_gmt":"2024-05-18T03:08:31","guid":{"rendered":"https:\/\/codebox.keyframetechsolution.com\/?p=144"},"modified":"2025-12-13T06:52:44","modified_gmt":"2025-12-13T06:52:44","slug":"autoplay-carousel-with-hover-pause","status":"publish","type":"post","link":"https:\/\/codebox.keyframetechsolution.com\/autoplay-carousel-with-hover-pause\/","title":{"rendered":"Autoplay Carousel with Hover Pause using HTML CSS and JavaScript"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p><span data-preserver-spaces=\"true\">Carousels are a commonly used feature on websites to showcase multiple images, content, or products in an organized and visually appealing way.<\/span><\/p>\n<p><span data-preserver-spaces=\"true\">They can <\/span><span data-preserver-spaces=\"true\">be set<\/span><span data-preserver-spaces=\"true\"> to automatically transition between slides, giving users a smooth and continuous experience. <\/span><\/p>\n<p><span data-preserver-spaces=\"true\">In this tutorial, I will explain how to create an autoplay carousel with a hover pause using HTML, CSS, and JavaScript. <\/span><\/p>\n<p>By the end of this article, you\u2019ll have a full understanding of how a carousel automatically transitions through slides and pauses when hovered over.<\/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\/pcxDmjUBba0?si=v5sEvpg58JettsNn\" 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<h2>Table of Contents<\/h2>\n<ul>\n<li><a href=\"#section1\">What is an Autoplay Carousel?<\/a><\/li>\n<li><a href=\"#section2\">What are the Steps to Begin?<\/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=\"#section5\">JavaScript Code Structure<\/a><\/li>\n<li><a href=\"#section6\">Testing the Carousel<\/a><\/li>\n<li><a href=\"#conclusion\">Conclusion<\/a><\/li>\n<\/ul>\n<\/div>\n<h2 id=\"section1\">What is an Autoplay Carousel?<\/h2>\n<p>An autoplay carousel is a popular feature on websites that automatically cycles through images or content.<\/p>\n<p>It provides a dynamic way to showcase multiple items, such as products or photos, in a limited space.<\/p>\n<p>It automatically transitions between slides at a set interval, requiring no user interaction.<\/p>\n<p>It can be customized with various settings, like speed, transition effects, and navigation controls.<\/p>\n<p>Adding a hover-to-pause feature is a great way to enhance user experience, allowing users to pause the automatic transitions when they hover over the carousel.<\/p>\n<p>This creates a smooth, interactive browsing experience for visitors.<\/p>\n<p><strong>Similar Posts:<\/strong> <a href=\"https:\/\/codebox.keyframetechsolution.com\/autoplay-carousel-html-css-js\/\">Responsive Autoplay Carousel using HTML CSS and JavaScript<\/a><\/p>\n<h3 id=\"section2\"><span data-preserver-spaces=\"true\">What are the Steps to Begin?<\/span><\/h3>\n<p><span data-preserver-spaces=\"true\">First, create a folder on your computer and add the following files inside it:<\/span><\/p>\n<ul>\n<li><span data-preserver-spaces=\"true\">index.html<\/span><\/li>\n<li><span data-preserver-spaces=\"true\">style.css<\/span><\/li>\n<li><span data-preserver-spaces=\"true\">script.js<\/span><\/li>\n<\/ul>\n<h2><span data-preserver-spaces=\"true\">Source Code<\/span><\/h2>\n<h3 id=\"section3\"><span data-preserver-spaces=\"true\">HTML Code Structure<\/span><\/h3>\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<\/p><\/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;Autoplay Carousel with Hover Pause using HTML CSS and JavaScript&lt;\/title&gt;\r\n  &lt;link rel=\"stylesheet\" href=\"style.css\"&gt;\r\n  &lt;link rel=\"stylesheet\" href=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/font-awesome\/4.7.0\/css\/font-awesome.min.css\"&gt;\r\n  &lt;script src=\"https:\/\/code.jquery.com\/jquery-3.5.1.min.js\"&gt;&lt;\/script&gt;\r\n  &lt;script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/typed.js\/2.0.11\/typed.min.js\"&gt;&lt;\/script&gt;\r\n  &lt;script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/waypoints\/4.0.1\/jquery.waypoints.min.js\"&gt;&lt;\/script&gt;\r\n  &lt;script src=\"https:\/\/cdn.jsdelivr.net\/npm\/bootstrap@5.3.0-alpha1\/dist\/css\/bootstrap.min.css\"&gt;&lt;\/script&gt;\r\n  &lt;link rel=\"stylesheet\" href=\"https:\/\/fonts.googleapis.com\/css2?family=Poppins:wght@400;500;600;700&amp;family=Ubuntu:wght@400;500;700&amp;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;script src=\"https:\/\/cdn.jsdelivr.net\/npm\/bootstrap@5.3.0-alpha1\/dist\/js\/bootstrap.bundle.min.js\"&gt;&lt;\/script&gt;\r\n&lt;script src=\"script.js\"&gt;&lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/code><\/pre>\n<\/p><\/div>\n<\/div>\n<h3 id=\"section4\"><span data-preserver-spaces=\"true\">CSS Code Structure<\/span><\/h3>\n<p><span data-preserver-spaces=\"true\">Now that <\/span><span data-preserver-spaces=\"true\">we\u2019ve<\/span><span data-preserver-spaces=\"true\"> defined the <\/span><span data-preserver-spaces=\"true\">structure,<\/span> <span data-preserver-spaces=\"true\">let\u2019s<\/span><span data-preserver-spaces=\"true\"> style it using CSS. <\/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\">style.css<\/div>\n<\/p><\/div>\n<div class=\"code-content\">\n<pre><code class=\"language-markup\">\r\n&lt; \/* Your CSS code here *\/ &gt;\r\n&lt; * { &gt;\r\n\r\n&lt; margin: 0; &gt;\r\n&lt; padding: 0 &gt;\r\n&lt; box-sizing: border-box; &gt;\r\n&lt;     text-decoration: none; &gt;\r\n&lt;     } &gt;\r\n      <\/code><\/pre>\n<\/p><\/div>\n<\/div>\n<h3 id=\"section5\"><span data-preserver-spaces=\"true\">JavaScript Code Structure<\/span><\/h3>\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\">script.js<\/div>\n<\/p><\/div>\n<div class=\"code-content\">\n<pre><code class=\"language-markup\">\r\n&lt; \/\/ JavaScript Code &gt;\r\n      <\/code><\/pre>\n<\/p><\/div>\n<\/div>\n<h2 id=\"section6\"><span data-preserver-spaces=\"true\">Testing the Carousel<\/span><\/h2>\n<p><span data-preserver-spaces=\"true\">Open your webpage in a browser, and you should see the carousel automatically cycling through the slides every 3 seconds. <\/span><\/p>\n<p><span data-preserver-spaces=\"true\">When you hover over it will pause, and when you move your mouse away, it will resume autoplay.<\/span><\/p>\n<p><strong>You may also like:<\/strong> <a href=\"https:\/\/codebox.keyframetechsolution.com\/3d-rotating-carousel-with-animated-background\/\">3D Rotating Carousel with HTML CSS and JavaScript<\/a><\/p>\n<h2 id=\"conclusion\"><span data-preserver-spaces=\"true\">Final Thoughts<\/span><\/h2>\n<p>Building an autoplay carousel with a hover pause is a great project for creating interactive content on a website.<\/p>\n<p><span data-preserver-spaces=\"true\">You can extend this functionality by adding navigation buttons, indicators, or even touch\/swipe support for mobile devices. <\/span><\/p>\n<p><span data-preserver-spaces=\"true\">Additionally, if you want to improve accessibility, consider adding aria-labels or keyboard navigation support.<\/span><\/p>\n<p><span data-preserver-spaces=\"true\">It is a versatile tool<\/span><span data-preserver-spaces=\"true\"> for displaying content<\/span><span data-preserver-spaces=\"true\">, and this<\/span><span data-preserver-spaces=\"true\"> technique is commonly used on product pages, image galleries, and promotional banners.<\/span><\/p>\n<p><strong><i class=\"fa fa-download\" style=\"color: #046bd2;\"><\/i> 18 people bought this<\/strong><\/p>\n<p><strong>Grab it Now for Just <i class=\"fa fa-rupee\" style=\"color: #046bd2;\"><\/i><span style=\"color: #046bd2;\">100<\/span><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Carousels are a commonly used feature on websites to showcase multiple images, content, or products in an organized and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":145,"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":[5],"tags":[425,426,427,428],"class_list":["post-144","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-image-slider","tag-automatic-carousel-html-css-javascript","tag-autoplay-carousel","tag-carousel-autoplay-hover-pause","tag-carousel-autoplay-smooth"],"acf":[],"_links":{"self":[{"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/posts\/144","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=144"}],"version-history":[{"count":10,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/posts\/144\/revisions"}],"predecessor-version":[{"id":2040,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/posts\/144\/revisions\/2040"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/media\/145"}],"wp:attachment":[{"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/media?parent=144"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/categories?post=144"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/tags?post=144"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}