How to add CSS properties to an element dynamically using jQuery ? Last Updated : 11 May, 2023 Comments Improve Suggest changes Like Article Like Report In this article, we will see how to add some CSS properties dynamically using jQuery. To add CSS properties dynamically, we use css() method. The css() method is used to change the style property of the selected element. The css() method can be used in different ways. This method can also be used to check the present value of the property for the selected element: Syntax: $(selector).css(property) Here we have created two elements inside the body tag i.e. <h1> and <h3> elements. We apply CSS property on the <body> tag and <h1> tag using CSS () method dynamically. Example: In this example, we will add CSS properties to an element using jQuery. HTML <!DOCTYpe html> <html> <head> <title> How to add CSS properties to an element dynamically using jQuery? </title> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </script> <script> $(document).ready(function () { $("body").css("text-align", "center"); $("h1").css("color", "green"); }); </script> </head> <body> <h1>GeeksforGeeks</h1> <h3> How to add CSS properties to an element <br>dynamically using jQuery? </h3> </body> </html> Output: Comment More infoAdvertise with us Next Article How to add CSS properties to an element dynamically using jQuery ? V vkash8574 Follow Improve Article Tags : Web Technologies JQuery HTML-Tags jQuery-Methods HTML-Questions jQuery-Questions +2 More Similar Reads How to add `style=display:âblockâ` to an element using jQuery? To add the inline style style="display: block" to HTML elements using jQuery, there are several approaches, each with its advantages. Below are the different methods you can use:Table of ContentUsing the CSS() methodUsing the show() methodUsing the attr() methodUsing the prop() methodUsing the CSS() 3 min read How to apply css property to a child element using JQuery? The task is to apply CSS property to a child element using jQuery. To do that, first we select the child element with the help of children() method in jQuery and then apply CSS property to it with the help of css() method in jQuery. Syntax: // Note : children method selects the direct child to paren 2 min read How to add and remove CSS classes to an element using jQuery ? In this article, we will see how to add or remove the CSS classes to an element using jQuery. To add the CSS classes to an element we use addClass() method, and to remove the CSS classes we use removeClass() method. Syntax: The syntax for adding CSS classes to an element: $('selector').addClass(clas 2 min read How to apply CSS in a particular div element using jQuery ? In this article, we will set the CSS of a div element using jQuery. We will use the CSS property to set the CSS.Approach: We will create a div element with some text and hyperlinks. Then we will use jQuery to apply CSS to the div element. jQuery comes with the function .css() where we can get and se 2 min read How to apply styles on an element using jQuery ? In this article, we will learn how one can apply a style on an element using jQuery. Suppose you are building a website or game where you need the user interface to be interactive. In such cases styles can play a huge role there in this post we are going to learn how can we change styles when certai 3 min read Like