How to apply CSS properties using jQuery?

To apply CSS properties using jQuery, use the css() method. It’s easy to apply any CSS property using jQuery method css( PropertyName, PropertyValue ).

Here is the syntax for the method −

selector.css( PropertyName, PropertyValue );


Here you can pass PropertyName as a JavaScript string and based on its value, PropertyValue could be string or integer.

Live Demo


      <title>jQuery css() method</title>
      <script src = ""></script>
         $(document).ready(function() {
            $("li").eq(4).css("color", "green");
            <li>list item 1</li>
            <li>list item 2</li>
            <li>list item 3</li>
            <li>list item 4</li>
            <li>list item 5</li>
            <li>list item 6</li>

Updated on: 18-Dec-2019


Kickstart Your Career

Get certified by completing the course

Get Started