How to change the text alignment using jQuery ? Last Updated : 12 May, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will see how to change the text alignment of an element using jQuery. To change the text alignment of an element, we will use css() method. The css() method is used to change the style property of the selected element. Syntax: $(selector).css(property) In the below example, first, we create an <h3> element containing an id attribute and also create a button element. When the user clicks on the button, the css() method is called and this method sets the text-align property value to the center. Example: In this example, we will change the text alignment using jQuery. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Including jQuery --> <script src=" https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </script> </head> <body> <h1 style="color: green;"> GeeksforGeeks </h1> <h3> How to change the text alignment using jQuery ? </h3> <h3 id="content"> Welcome to GeeksforGeeks </h3> <br> <button>Change font size</button> <script> $(document).ready(function() { $('button').click(function() { $("#content").css("textAlign", "center"); }); }); </script> </body> </html> Output: Comment More infoAdvertise with us Next Article How to override the current text direction using HTML ? V vkash8574 Follow Improve Article Tags : HTML jQuery-Methods HTML-Questions jQuery-Questions Similar Reads How to Change the Placeholder Text using jQuery? We can change the placeholder Text of an input element using the attr() attribute and placeholder property of jQuery. We will create a button and on clicking the button the text of the placeholder will be changed dynamically.Below are the approaches to change the placeholder text using jQuery:Table 2 min read How to Change the Placeholder Text using jQuery? We can change the placeholder Text of an input element using the attr() attribute and placeholder property of jQuery. We will create a button and on clicking the button the text of the placeholder will be changed dynamically.Below are the approaches to change the placeholder text using jQuery:Table 2 min read How to change font size using jQuery ? In this article, we will see how to change the font size of an element using jQuery. To change the font size of an element, we will use css() method. The css() method is used to change the style property of the selected element. Syntax: $(selector).css(property) Return value: It will return the valu 1 min read How to append some text to all paragraphs using jQuery ? In this article, we will append some text to all paragraph elements using jQuery. To append some text to all paragraph elements, we use append() and document.createTextNode() methods. jQuery append() method is used to insert some content at the end of the selected elements. Syntax: $(selector).appen 1 min read How to override the current text direction using HTML ? In this article, we will override the current text direction by using the dir attribute in the particular element. It is used to specify the text direction of the element content. It contains three values: ltr: It is the default value. This value represent the text in Left-to-right text direction. r 1 min read How to make first word bold of all elements using jQuery ? In this article, we will make first word bold of all elements using jquery. To make the first word bold, we use html(), and text() methods. html() Method: The html() method in jQuery is used to set or return the innerHTML content of the selected element. Syntax: It sets the content of matched elemen 1 min read Like