JavaScript Code

jQuery – Left align text in element(s)

Left align text in HTML Element(s) using jQuery

Selected some HTML elements in the document, align the text in the elements to left side using jQuery.


To left align text in selected HTML elements using jQuery, call css() function on the selected elements and pass the arguments: "text-align" CSS property, and "left" value for the CSS property.

For example, the syntax to left align text in all paragraphs in the document is

$("p").css("text-align", "left");


1. Left align text in paragraphs in the document.

<!DOCTYPE html>
      p {
        text-align: center;
    <script src=""></script>
      function myAction() {
        $("p").css("text-align", "left");
    <button onclick="myAction()">Left align text in paragraphs</button>
    <p style="background:yellow;">This is paragraph.</p>

copyright @2023