How to change the text alignment using jQuery ? Last Updated : 12 May, 2023 Comments Improve Suggest changes 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 change the text alignment using jQuery ? 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 create a news ticker using jQuery ? A news ticker is a text-based display either in the form of a graphic that displays news scrolling text running from up to down or right to left. In this article, we will use a jQuery plugin called easy-ticker to create a news ticker in a simple manner. To use this plugin, simply add the CDN link in 3 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 How to Align <legend> Tag Text to Center ? The <legend> tag is used to define the title for the child contents. The legend elements are the parent element. This tag is used to define the caption for the <fieldset> element.The <legend> align attribute in HTML is used to specify the alignment of the caption in a <fieldset 2 min read How to use jQuery to Search and Replace HTML elements? Using jQuery, you can dynamically search and replace HTML elements on a webpage. By selecting elements and binding actions to events, you can manipulate their content or structure in response to user interactions or other triggers ApproachIntegrate the jQuery library hosted on a content delivery net 2 min read How to Align Text in a Table Header and Body? Tables are a fundamental structure in HTML for organizing data into rows and columns. Aligning the text within these cells is crucial for readability and presentation. Properly aligning text in table headers and bodies not only enhances readability but also improves the overall aesthetic of your dat 4 min read How to align Placeholder Text in HTML ? The placeholder attribute specifies a short hint that describes the expected value of an input field/text area. The short hint is displayed in the field before the user enters a value. In most of the browsers, placeholder texts are usually aligned on the left. The selector uses the text-align proper 2 min read Like