Hello, fastq123:
Check out this code snippet I created based on your request. Please keep in mind that you'll need vanilla JavaScript or jQuery to accomplish this task. I opted for jQuery for speed, but either method will work. I hope this code is useful for you. Happy coding!
// Get the DOM element P and store it in a variable
p = document.getElementById("paragraph");
// Store the text content of p in another variable
let strParagraph = p.innerHTML;
// Convert the text into an array
let strArray = strParagraph.split(" ");
// Get the last element in the array
let last_element = strArray[strArray.length - 1];
.reverse {
text-align:center;
width:420px;
}
.reverse {
position: absolute;
left: 93px;
top: 21px;
width: 65%;
height:60%;
display: table;
}
.reverse p {
display: table-cell;
vertical-align: middle;
text-align: justify;
}
.reverse p::first-line {
text-align: center;
}
<div class="reverse">
<p id="paragraph">lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum. lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum. lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum. lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum.lorem ipsum lorem ipsum.
</p></div>