Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
How to set the horizontal alignment of text with JavaScript?
Use the textAlign property in JavaScript and set it to right for aligning it horizontally. You can try to run the following code to return the horizontal alignment of text with JavaScript −
Example
<!DOCTYPE html>
<html>
<body>
<p id = "myText">This is demo text</p>
<button onclick = "display()">Set Horizontal Alignment</button>
<script>
function display() {
document.getElementById("myText").style.textAlign = "right";
}
</script>
</body>
</html> Advertisements
