EN
CSS - text align right
0
points
In this article, we would like to show you how to align text to the right using CSS.
Quick solution:
.element {
text-align: right;
}
Practical example
In this example, we create a style for .element
class that uses text-align
property to align text inside div
element to the right side.
// ONLINE-RUNNER:browser;
<!doctype>
<html>
<head>
<style>
.element {
text-align: right; /* <---------- required */
border: 1px solid lightgray;
}
</style>
</head>
<body>
<div class="element">Some text here...</div>
<br />
<div class="element">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div>
</body>
</html>
Note:
You can also use
text-align: end
which is a new standard solution, however it is supported by all major browsers since 2020. For legacy purposes, we usetext-align: right
in the example.