Getting Started with Owl Carousel: Installation and Your First Slider

Owl Carousel turns an ordinary group of HTML elements into a touch-enabled, responsive slider. Getting a first carousel on screen takes only a few minutes, provided the files load in the right order and the markup follows the structure the library expects. This guide walks through each stage and explains what to check if nothing appears.
Why Owl Carousel Remains a Practical Choice
Many slider libraries have appeared since Owl Carousel was first released, yet it continues to power a large number of live websites. The reasons are practical rather than fashionable. It works with markup that already exists, so a list of images or cards can become a carousel without being rewritten. Its options are descriptive and largely self-explanatory, which shortens the time needed to understand an unfamiliar project. It also has a long history of answered questions and published examples, so most problems have already been solved somewhere.
The library is most at home on sites that already include jQuery, such as many WordPress themes, Shopify themes and older Bootstrap projects. Adding it there costs little, because the main dependency is already loaded. On a new site with no jQuery at all, weigh the extra download against the convenience; for a single small carousel, a lighter alternative may suit better, while for several feature-rich sliders Owl Carousel's breadth of options often justifies the cost.
How Owl Carousel Transforms Your Markup
When initialisation runs, the library restructures the container. It wraps the original children in a stage element, wraps that stage in an outer element that hides overflow, and gives every slide its own item wrapper. The stage is then moved with CSS transforms to bring different slides into view. Knowing this structure explains several behaviours that otherwise seem puzzling: why a parent with an unusual width affects the slides, why styles should target .owl-item rather than the original children for layout, and why the container must be visible when the library measures it.
What You Need
Owl Carousel is built on jQuery, so jQuery must be present on the page before the Owl Carousel script runs. Version 2.3.4 of Owl Carousel recommends jQuery 1.8.3 or later. Beyond that, you need three files:
owl.carousel.min.css, the core stylesheet that controls layout and positioningowl.theme.default.min.css, an optional theme that styles the navigation buttons and dotsowl.carousel.min.js, the library itself
You can obtain these by installing the package with npm install owl.carousel, by referencing the copies hosted on cdnjs, or by extracting them from a downloaded source archive. Whichever route you choose, keep the CSS and JavaScript from the same release to avoid subtle mismatches.
Step 1: Load the Stylesheets
Place both stylesheets inside the document head. The core file is essential; the theme file can be replaced later with your own styles.
<link rel="stylesheet" href="css/owl.carousel.min.css">
<link rel="stylesheet" href="css/owl.theme.default.min.css">
Step 2: Write the Markup
Create a container with the class owl-carousel. Every direct child of that container becomes one slide, so there is no need for wrapper lists or special attributes. Adding owl-theme applies the default theme to the controls.
<div class="owl-carousel owl-theme">
<div class="item"><img src="img/slide-1.jpg" alt="Harbour at sunrise"></div>
<div class="item"><img src="img/slide-2.jpg" alt="Mountain trail"></div>
<div class="item"><img src="img/slide-3.jpg" alt="City skyline"></div>
</div>
Step 3: Load the Scripts in Order
Scripts belong just before the closing body tag. jQuery must come first, because the library attaches itself to the jQuery object as soon as it loads. Reversing the order is the single most common cause of a broken installation.
<script src="js/jquery.min.js"></script>
<script src="js/owl.carousel.min.js"></script>
Step 4: Initialise the Carousel
Call the library once the document is ready. Passing an options object lets you shape behaviour from the outset; even an empty call produces a working carousel with three items visible.
$(function () {
$(".owl-carousel").owlCarousel({
items: 3,
margin: 16,
nav: true,
loop: true
});
});
Confirming That It Works
Open your browser's developer tools and inspect the container. After a successful initialisation, it carries the class owl-loaded, and its children are wrapped in .owl-stage-outer, .owl-stage and individual .owl-item elements.
If the container is present but invisible, the core stylesheet has almost certainly failed to load. The stylesheet hides any .owl-carousel element until the library adds owl-loaded, which prevents a flash of unstyled content but also hides the markup entirely when the script never runs.
Choosing an Installation Method
There are three common ways to bring Owl Carousel into a project, and the right one depends on how the rest of the site is built.
- Local files suit traditional sites and content management systems. Copy the CSS and JavaScript into your asset folders and reference them directly.
- A CDN suits prototypes and small sites. Files load from a shared, globally cached network without any build step.
- npm suits projects that already use a bundler such as webpack or Vite, where dependencies are versioned in
package.json.
The cdnjs copies of version 2.3.4 follow a predictable path, which makes them easy to reference:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.theme.default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js"></script>
Using Owl Carousel with a Bundler
The library expects jQuery to exist as a global variable. In a module-based project, import statements are hoisted to the top of the file, so assigning the global in the same file as the library import happens too late. Placing the assignment in a small module of its own, imported first, solves this reliably.
// jquery-global.js
import $ from "jquery";
window.jQuery = window.$ = $;
// main.js
import "./jquery-global.js";
import "owl.carousel/dist/assets/owl.carousel.css";
import "owl.carousel/dist/assets/owl.theme.default.css";
import "owl.carousel";
$(".owl-carousel").owlCarousel({ items: 3 });
Styling the Slides
The library calculates the width of every item for you, so avoid fixed widths on the slides themselves. The core stylesheet already makes images inside items display as blocks at full width, which means an image simply fills its slide. To keep every slide the same height regardless of the source image, set an aspect ratio and let the image cover the area:
.owl-carousel .item img {
aspect-ratio: 4 / 3;
object-fit: cover;
border-radius: 10px;
}
Common First-Time Mistakes
- Wrapping the slides in an extra element. If the container holds a single
ul, that list becomes one slide; the slides must be direct children of.owl-carousel. - Running the initialisation before the markup exists. Place the call inside a document-ready handler or at the end of the body.
- Omitting
owl-theme. Without it, the default theme cannot style the dots and arrows, which then appear as unstyled buttons. - Placing the carousel inside an element hidden with
display: none. The library cannot measure a hidden container, so slides collapse to zero width.
A Complete Starter Page
The page below combines every step into a single file that you can open in a browser and adapt:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Owl Carousel starter</title>
<link rel="stylesheet" href="css/owl.carousel.min.css">
<link rel="stylesheet" href="css/owl.theme.default.min.css">
</head>
<body>
<div class="owl-carousel owl-theme">
<div class="item"><img src="img/1.jpg" alt="Slide one"></div>
<div class="item"><img src="img/2.jpg" alt="Slide two"></div>
<div class="item"><img src="img/3.jpg" alt="Slide three"></div>
<div class="item"><img src="img/4.jpg" alt="Slide four"></div>
</div>
<script src="js/jquery.min.js"></script>
<script src="js/owl.carousel.min.js"></script>
<script>
$(function () {
$(".owl-carousel").owlCarousel({
loop: true,
margin: 16,
nav: true,
responsive: { 0: { items: 1 }, 700: { items: 2 }, 1100: { items: 3 } }
});
});
</script>
</body>
</html>
Key Takeaways
- Load jQuery before the library, and the stylesheet before either.
- Every direct child of
.owl-carouselbecomes one slide. - An invisible container usually means the stylesheet or script failed.
- Choose local files, a CDN or npm according to how the site is built.
Where to Go Next
With a working carousel in place, the natural next steps are configuring breakpoints so that the number of visible items suits each screen size, and adjusting the navigation controls to match your design. Both topics have dedicated guides in this series.


