Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Using jQuery Plugins Using a jQuery Carousel The Carousel Challenge Solution

Peter Retvari
Peter Retvari
Full Stack JavaScript Techdegree Student 8,392 Points

Solved the 4 slides to show in different way

Hi folks,

I did the 4 slides to show challenge in a different way, because I saw the illustration on the top of this page:


Could someone tell me how this code works? Is it an inline style? But where is the style attribute or we can pick up a name whatever we want instead of style ? ?? Where data-slick comes from?

<div data-slick='{"slidesToShow": 4, "slidesToScroll": 4}'>

1 Answer

Wiktor Bednarz
Wiktor Bednarz
18,647 Points

Hello Peter,

your question is considering the inner workings of the plugin itself. But I'll try to shed some light on the main principle.

First of all, the "data-slick" attribute of the parent div is a so called custom data. When you invoke it in your html, then it's pretty much as if you called a .slick function with specified attributes in your script file. So in other words, it's more or less similar to this snippet of code in js:

  slidesToShow: 4,
  slidesToScroll: 4

I refer you to the MDN documentation on the custom data html attribute:


If it goes for the styles, they're applied by default by the plugin. So whenever you invoke a slick method on your DOM object, the method itself loads whole list of default attributes. This default state also loads in any styles that should be applied to the DOM element you selected. All those basic styles are within the .css file attached to the plugin files. You can check what kind of classes/id's the plugin assigns to the selected DOM object with your browser's Dev Tools and then find and change them in the original plugin CSS or just override them in your own main .css file.

I hope that this answer satisfies you. Keep on coding mate!